I am having some problems with using subcollections (?) within a select new {}.
Using the latest beta and Northwind
Take the following code
from e in db.Employees
select new {
e.LastName,
OrderCount = e.Orderss.Count()
}
This works fine, gives the total orders for each employee. Now if I introduce a join to the query:
from e in db.Employees
join et in db.EmployeeTerritories on e.EmployeeID equals et.EmployeeID
select new {
e.LastName,
OrderCount = e.Orderss.Count()
}
without even referencing 'et' in the select, it falls over with:
The property 'Orderss' isn't mapped to a field or database construct of entity type 'EmployeesEntity'. Did you mean to call an extension method instead? ('Count' vs. 'Count()') ?
I have also had the following error in a similar situation on another project, but havent been able to reproduce it in my test Northwind project yet. Like above it works fine until a join is introduced.
System.InvalidCastException : Unable to cast object of type 'System.Linq.Expressions.MemberExpression' to type 'SD.LLBLGen.Pro26.LinqSupportClasses.ExpressionClasses.SetExpression'.
I will post the code to make this error as soon as I have reproduced it.
Any ideas? Is this possible?
Many Thanks!