Open GoogleCodeExporter opened 9 years ago
A Northwind-based test that exhibits the same error:
[Test]
public void NestedJoin()
{
var db = CreateDB();
var q = from s in db.Suppliers
where s.SupplierID == 1
select new
{
ID = s.SupplierID,
Title = s.ContactTitle,
Products = from p in s.Products
join pl in db.Products on s.SupplierID equals
pl.SupplierID
select new
{
ID = pl.ProductID,
Name = pl.ProductName
}
};
foreach (var e in q)
{
Console.WriteLine("# ID={0}; Title={1}", e.ID, e.Title);
foreach (var p in e.Products)
{
Console.WriteLine ("# ID={0}; Name={1}", p.ID, p.Name);
}
}
}
Linq-to-SQL's output:
SELECT [t0].[SupplierID] AS [ID], [t0].[ContactTitle] AS [Title],
[t3].[ProductID] AS
[ID2], [t3].[ProductName] AS [Name], (
SELECT COUNT(*)
FROM [dbo].[Products] AS [t4]
INNER JOIN [dbo].[Products] AS [t5] ON ([t0].[SupplierID]) = [t5].[SupplierID]
WHERE [t4].[SupplierID] = [t0].[SupplierID]
) AS [value]
FROM [dbo].[Suppliers] AS [t0]
OUTER APPLY (
SELECT [t2].[ProductID], [t2].[ProductName], [t1].[ProductID] AS [ProductID2]
FROM [dbo].[Products] AS [t1]
INNER JOIN [dbo].[Products] AS [t2] ON ([t0].[SupplierID]) = [t2].[SupplierID]
WHERE [t1].[SupplierID] = [t0].[SupplierID]
) AS [t3]
WHERE [t0].[SupplierID] = @p0
ORDER BY [t0].[SupplierID], [t3].[ProductID2], [t3].[ProductID]
-- @p0: Input Int (Size = 0; Prec = 0; Scale = 0) [1]
-- Context: SqlProvider(Sql2008) Model: AttributedMetaModel Build:
3.5.30729.4926
# ID=1; Title=Purchasing Manager
# ID=1; Name=Chai
# ID=2; Name=Chang
# ID=3; Name=Aniseed Syrup
# ID=1; Name=Chai
# ID=2; Name=Chang
# ID=3; Name=Aniseed Syrup
# ID=1; Name=Chai
# ID=2; Name=Chang
# ID=3; Name=Aniseed Syrup
Original comment by jonmpr...@gmail.com
on 22 Jan 2010 at 9:31
I've got the same problem. It's a long time since March 2009. Did you resolve
it?
Original comment by haonv...@gmail.com
on 18 Jan 2011 at 1:55
Same problem here...
Original comment by zil...@hotmail.com
on 16 Feb 2011 at 9:46
Original issue reported on code.google.com by
bosak.to...@gmail.com
on 3 Dec 2009 at 1:53Attachments: