(see below for full playback)
With the following object ...
[Table] internal sealed class Employee { private EntityRef<Employee> manager; [Column(IsPrimaryKey = true, IsDbGenerated = true)] private int Id; [Column] private int? ManagerId; [Column] internal bool IsOverpaid; [Association(Name = "Manager_Subordinate", Storage = "manager", ThisKey = "ManagerId", IsForeignKey = true)] internal Employee Manager { get { return this.manager.Entity; } set { this.manager.Entity = value; } } }
... this request failed with a NotSupportedException error, with the message "Types in union or Concat" built incompatible. ":
var overpaidTopManagers = from employee in context.Employees where employee.IsOverpaid && (employee.Manager == null) select employee; var managersWithOverpaidSubordinates = from employee in context.Employees where employee.IsOverpaid && (employee.Manager != null) select employee.Manager; var query = overpaidTopManagers.Union(managersWithOverpaidSubordinates);
I really donโt understand why both queries create the same type of entity, so it should not be a problem to combine them?
The following is the full text:
using System; using System.Data.Linq; using System.Data.Linq.Mapping; using System.Linq; internal static class Program { private static void Main(string[] args) { using (var context = new Context("Whatever.sdf")) { if (!context.DatabaseExists()) { context.CreateDatabase(); } var overpaidTopManagers = from employee in context.Employees where employee.IsOverpaid && (employee.Manager == null) select employee; var managersWithOverpaidSubordinates = from employee in context.Employees where employee.IsOverpaid && (employee.Manager != null) select employee.Manager; var query = overpaidTopManagers.Union(managersWithOverpaidSubordinates);
Andreas Huber
source share