I think I can reproduce it using my example in your other thread:
RTL
ORMSupportClasses: 3.5.13.108
LinqSupportClasses: 3.5.12.1211
Reproduce code
[TestMethod]
public void WeirdCorrelationInnerQuery2()
{
var adapter = new DataAccessAdapter();
var ctx = new LinqMetaData(adapter);
var x = from sm in ctx.ShipMethod
where sm.PurchaseOrdes.Any(po => new int[] { 2, 5 }.Contains(po.VendorId))
select new
{
Vendors = (from po in sm.PurchaseOrdes
from v in ctx.Vendor
where v.VendorId == po.VendorId
select v).ToList()
};
var results = x.ToList();
}
Generated SQL
SELECT 1 AS [LPFA_4],
[LPLA_2].[VendorID] AS [VendorId]
FROM [AdventureWorks].[Purchasing].[ShipMethod] [LPLA_1]
WHERE ((((EXISTS
(SELECT [LPLA_2].[VendorID] AS [VendorId]
FROM [AdventureWorks].[Purchasing].[PurchaseOrderHeader] [LPLA_2]
WHERE ([LPLA_1].[ShipMethodID] = [LPLA_2].[ShipMethodID]
AND ([LPLA_2].[VendorID] IN (@p1, @p2))))))))
Exception (stack trace attached)
Exception type: System.Data.SqlClient.SqlException
Message: The multi-part identifier "LPLA_2.VendorID" could not be bound.
The weird thing is that apparently the code shouldn't work at all because the inner query projection ('v' as Vendors) doesn't have any correlated field that links to the parent query. If you remove the filter on the parent query...
var x = from sm in ctx.ShipMethod
select new
{
Vendors = (from po in sm.PurchaseOrdes
from v in ctx.Vendor
where v.VendorId == po.VendorId
select v).ToList()
};
... the exception is different:
SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryConstructionException: A nested query in the projection has no correlation filter to tie its set to the containing parent row. Please add a correlation filter to the where clause of this query to tie the nested query to the parent.
Maybe you should use a PrefetchPath here...
Attachments
Filename |
File size |
Added on |
Approval |
stackTrace.txt
|
5,112 |
27-Mar-2013 07:46.22 |
Approved |