c# - Linq where on include -


i'm stuck linq query.

i've tables.

id    b   c  d 1   data  2   other data 

then, every record on table may have none or many rows

id  tablea_id r 1   1         1 2   1         2 3   1         5 4   2         2 

for example. row 1 (some data) has 3 rows on table b.

i tried using

tablea.include(x => x.tablebchilds.where( d => d.r == 1)).tolist()  

but not working. many others varation.

the objective of query return tablea.row #1 if pass 1 value (value of r). number <> 2 won't give result.

tables linked on ef. tableb.tablea_id foreign key of tablea.id

edit #1

i tried answers in question marked duplicated no luck. give 2 tablea.rows if user insert 1 parameter, linq query should return row #1, data. if 2 passed parameter, nothing return.

a working sql statement is:

select [tablea].* [tablea] join [tableb] on [tablea].[id] = [tableb].[tablea_id] [tableb].[r] = 1 

thanks!

if have database relationship configured have work.

tablea.include(x => x.tablebchilds).where(tablea => tablea.tablebchilds.any(b => b.r== 1)).tolist(); 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -