Linq Search on Child

Linq Search on Child

Old forum URL: forums.lhotka.net/forums/t/11394.aspx


tanny posted on Monday, June 04, 2012

All,

I have parent and child class.  For example, my parent class is Customers and child class is CustomerDetails.

I wanted to load all customers with state as NY (where state is property in customer details ). Could someone let me know how this can be done using LINQ?

from p in DataContextObj.Customers where p.CustomerDetails..... ??

 

Regards,

Tanny

RockfordLhotka replied on Monday, June 04, 2012

You are using the Entity Framework and are using LINQ to Entities?

Or you want to do this query against a graph of business objects already in memory?

tanny replied on Tuesday, June 05, 2012

Thanks for the reply. I'm using LINQ to SQL classes.

I was also able to achieve what I wanted. I tried using the LINQ query below and it worked.

from p in DataContextObj.Customers where p.CustomerDetails.Any (x => x.State == "NY")

Copyright (c) Marimer LLC