I have the following table structure which has been imported into the Entity Framework. I need to write a LINQ query where I select the entities of Table1, where a field in Table2 is equal to true, and a field in Table 3 is equal to a specific GUID.
Could someone help with this?
Thanks you.
alt text http://digitalsamurai.us/images/drawing2.jpg
Try:
from t3 in dataContext.Table3
where t3.Guidfield == someGuid
from t2 in t3.Table2
where t2.Field // boolean field is true
select t2.Table1;
EDIT: As requested, equivalent lambda expression syntax:
dataContext.Table3.Where(t3 => t3.Guidfield == someGuid)
.SelectMany(t3 => t3.Table2)
.Where(t2 => t2.Field)
.Select(t2.Table1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With