|
Hi,
I am getting an error during the execution of a query on a model where exist TPH inheritance.
EntityServerException: Une expression de type 'System.Data.Objects.ObjectQuery`1[ConsoleApplication4.Company]' ne peut pas être utilisée pour un paramètre de type 'System.Linq.IQueryable`1[ConsoleApplication4.GamingCompany]' d'une méthode 'System.Linq.IQueryable`1[ConsoleApplication4.GamingCompany] Where[GamingCompany](System.Linq.IQueryable`1[ConsoleApplication4.GamingCompany], System.Linq.Expressions.Expression`1[System.Func`2[ConsoleApplication4.GamingCompany,System.Boolean]])'
My model has an entity GamingCompany which inherit from the entity Company. The model looks like this : Here is the query from c in Customers
from o in c.Orders
let companyGroupId = (from e in GamingCompanies where (e.ID == 0) select e.CompanyGroupId).FirstOrDefault()
where (o.GamingCompany.CompanyGroupId == companyGroupId)
select c;
Now I made a model where I broke the inheritance and the modified query works.
var q = from c in Customers
from o in c.Orders
let companyGroupId = (from e in Companies where (e.ID == 0 && e.Discriminant == 1) select e.FirstOrDefault()
where (o.Company.CompanyGroupId == companyGroupId)
select c;
What am I doing wrong ? Is it not allowed to do subquery on a inherited entity ?
Regards,
EDIT : on the first model, if the CompanyGroup relation is on Company and not GamingCompany it's working. Unfortunatly I need it on GamingCompany ...
|