Reputation: 7702
I have the following T-SQL:
Select
MESReportHeaderID
From Report.MESReportHeader
Where
MESReportHeaderID IN (Select ParentID From Report.MESReportHeader) And
IsLeafLevel = 0
This would be fairly trivial to convert to Linq, if it wasn't for the IN statement. Could anyone help with this?
Thanks.
Upvotes: 0
Views: 185
Reputation: 532465
There may be more efficient ways to do it, but I think this is a pretty straight-forward translation using extension methods.
var headerIDs = ctx.ReportHeaders
.Where( r => ctx.ReportHeaders
.Select( rh => rh.ParentID )
.Contains( r.MESReportHeaderID )
&& !r.IsLeafLevel )
Upvotes: 2
Reputation: 156524
How about this:
from r in reportHeaders
where reportHeaders.Any(r2 => r2.ParentId == r.MESReportHeaderID)
Upvotes: 0