Hi, i was playing with Linq to LLBL and tried the following
var test = from c in metaData.Customer
join o in metaData.Order on c.CustomerID equals o.CustomerID
group new {c, o} by new {c, o} into g
select new { customer = g.Key, total = g.Sum(x => x.o.Price) };
Then I thought I could simply do
foreach (var t in test)
{
Console.WriteLine(t.customer.CustomerID + t.total);
}
but I get an exception
The multi-part identifier "LPLA_1.CustomerID" could not be bound.
The multi-part identifier "LPLA_2.OrderID" could not be bound.
The multi-part identifier "LPLA_2.CustomerID" could not be bound.
The multi-part identifier "LPLA_2.Price" could not be bound.
Generated Sql query:
Query: SELECT DISTINCT [LPA_L3].[CustomerID] AS [CustomerId], [LPA_L4].[OrderID] AS [OrderId], [LPA_L4].[CustomerID] AS [CustomerId0], [LPA_L4].[Price], SUM([LPA_L4].[Price]) AS [LPAV_] FROM ( [testdb].[dbo].[Customer] [LPA_L3] INNER JOIN [testdb].[dbo].[Order] [LPA_L4] ON [LPA_L3].[CustomerID] = [LPA_L4].[CustomerID]) GROUP BY [LPA_L3].[CustomerID], [LPA_L4].[OrderID], [LPA_L4].[CustomerID], [LPA_L4].[Price]
Method Exit: CreateSelectDQ
Method Exit: CreateSubQuery
Generated Sql query:
Query: SELECT [LPLA_1].[CustomerID] AS [CustomerId], [LPLA_2].[OrderID] AS [OrderId], [LPLA_2].[CustomerID] AS [CustomerId0], [LPLA_2].[Price], [LPA_L1].[LPAV_] AS [total] FROM (SELECT DISTINCT [LPA_L3].[CustomerID] AS [CustomerId], [LPA_L4].[OrderID] AS [OrderId], [LPA_L4].[CustomerID] AS [CustomerId0], [LPA_L4].[Price], SUM([LPA_L4].[Price]) AS [LPAV_] FROM ( [testdb].[dbo].[Customer] [LPA_L3] INNER JOIN [testdb].[dbo].[Order] [LPA_L4] ON [LPA_L3].[CustomerID] = [LPA_L4].[CustomerID]) GROUP BY [LPA_L3].[CustomerID], [LPA_L4].[OrderID], [LPA_L4].[CustomerID], [LPA_L4].[Price]) [LPA_L1]
What exactly is the 2nd query? I don't see the alias [LPLA_1] and [LPLA_2] defined anywhere?
Many thanks
SD.LLBLGen.Pro.DQE.SqlServer.NET20 ( 2.6.9.917 )
SD.LLBLGen.Pro.LinqSupportClasses.NET35 ( 2.6.9.1008 )
SD.LLBLGen.Pro.ORMSupportClasses.NET20 ( .6.9.1005 )