Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Selfreferencing JOIN blues
Message
General information
Forum:
C#
Category:
LINQ
Miscellaneous
Thread ID:
01657564
Message ID:
01657584
Views:
48
>Why is the code in linq not returning anything, whereas the sql is ok?
>
>
>var query = TransactionDetails.Join(TransactionDetails,x=>x.Parcels_Id ,y=> y.Parcels_Id ,(x,y) => new
>	{
>		x,
>		y,
>  		x.Parcel.RSReference,
>		xId = x.TransactionDetails_Id,
>		yId = y.TransactionDetails_Id, 
>		xDate = x.TransactionHeader.TransactionDate,
>		yDate = y.TransactionHeader.TransactionDate		
>	})
>	.Where(x => (x.xId>x.yId) && (x.xDate.CompareTo(x.yDate) == -1));
>
>
>
>select Parcels.RSReference,t1.Parcels_Id,th1.TransactionDate,th2.TransactionDate,t1.TransactionDetails_Id,t2.TransactionDetails_Id
>	from transactionDetails t1,transactionDetails t2,transactionHeaders th1,transactionHeaders th2,Parcels
>	where t1.Parcels_Id = t2.Parcels_Id
>	and t1.TransactionHeaders_Id = th1.TransactionHeaders_Id
>	and t2.TransactionHeaders_Id = th2.TransactionHeaders_Id
>	and Parcels.Parcels_Id = t1.Parcels_Id
>	and th1.TransactionDate > th2.TransactionDate
>	and t1.TransactionDetails_Id <t2.TransactionDetails_Id
>	order by Parcels.RSReference,th2.TransactionDate
>
Examining the SQL generated by the Linq should give a clue ?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform