LINQ group by with renamed fields

Posts   
 
    
NMcGuire
User
Posts: 3
Joined: 17-Sep-2008
# Posted on: 19-Nov-2008 01:08:03   

I have a database written by another person with horrible table and field names. I took the advantage that LLBLGen gives me to heart and renamed them more sensibly.

So, I have a table named Ticket (which is much better than Customer_Order_Product_List_Audit), with a field named Truck_ID. I want to select the tickets and group them by Truck_ID, and so run the following query:


var coll = (from t in db.Ticket
        group t by t.TruckId into grp
        select grp).ToList();

and I get the following information off the exception: "An exception was caught during the execution of a retrieval query: Invalid column name 'TruckId'.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception."

"Invalid column name 'TruckId'."

Query: SELECT [LPLA_4].[Ticket_ID] AS [TicketId], [LPLA_4].[Truck_ID] AS [TruckId], ... FROM [NRMJNL].[dbo].[Ticket] [LPLA_4]  WHERE ( ( ( (  EXISTS (SELECT [LPLA_2].[TruckId] FROM [NRMJNL].[dbo].[Ticket] [LPLA_2]  WHERE ( [LPLA_2].[Truck_ID] = [LPLA_4].[Truck_ID]))))))

Just wanted to let you know. I'll probably just end up going with the plain old syntax to solve this. Thanks.

Neil McGuire

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 19-Nov-2008 05:00:30   
Just wanted to let you know. I'll probably just end up going with the plain old syntax to solve this. Thanks.

Are you talking about IPredicateExpressions?

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 19-Nov-2008 11:27:22   

PLease use the latest build, this has been fixed some time ago.

Frans Bouma | Lead developer LLBLGen Pro
NMcGuire
User
Posts: 3
Joined: 17-Sep-2008
# Posted on: 19-Nov-2008 17:45:21   

Thanks, going from Sept 12 to Oct 6 fixed it.