c# - Generic Linq IN sub query expression -


i trying find way create linq expression tree sub-query in-clause.

select * x x.id in (select xid y) 

say have query, need way create system.linq.expression of clause. have generic repository base solution numerous entities , creating expression tree dynamically other filters , add created expression tree.

i know can below, isn't generic enough.

var xids = y.select(x => x.xid).tolist(); var final = x.where(x => xids.contains(x.id)).tolist(); 

but need expression tree create.

i played around link: creating linq expression dynamically containing subquery , doesn't seem work. might missing though, been staring @ while.

thanks!


Comments