SubCollections and Joins

Posts   
 
    
rossmcw
User
Posts: 28
Joined: 27-Mar-2008
# Posted on: 14-May-2008 08:14:21   

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!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 14-May-2008 10:17:59   

Should work, I'll check it out.

Btw, was that redundant 's' at the end of 'Orderss' introduced by the designer?

(edit) I ran into this now myself as well. Will look into it.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 14-May-2008 13:40:09   

Fixed it. See attached build

Frans Bouma | Lead developer LLBLGen Pro
rossmcw
User
Posts: 28
Joined: 27-Mar-2008
# Posted on: 14-May-2008 23:11:14   

Otis wrote:

Btw, was that redundant 's' at the end of 'Orderss' introduced by the designer?

Yes it was, but I might not have my project settings set right. simple_smile

Any chance of another source release, we have to recompile the runtimes for our environment due to namespace issues.

I will try and get the second error through northwind today.

Thanks again

rossmcw
User
Posts: 28
Joined: 27-Mar-2008
# Posted on: 15-May-2008 06:57:32   

The attached DLL fixed the issue. I was able to test it without the source, so all is good. Thanks again.

I think the second issue was due to me maybe mixing Objects with Database in the same query, which of course is a no no. simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 15-May-2008 08:55:09   

there are some open issues to fix before a new build can be released, expect one in a couple of days.

Frans Bouma | Lead developer LLBLGen Pro