New Posts New Posts RSS Feed: Querying through Multiple Levels
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Querying through Multiple Levels

 Post Reply Post Reply
Author
benmcneill View Drop Down
Newbie
Newbie
Avatar

Joined: 26-Aug-2010
Posts: 11
Post Options Post Options   Quote benmcneill Quote  Post ReplyReply Direct Link To This Post Topic: Querying through Multiple Levels
    Posted: 09-Sep-2010 at 2:56am
Hi Guys

Have been searching through the documentation but having trouble figuring this one out.

I have a Master table, say 'Baskets'. There is a many-to-many relationship to a Detail table 'Fruits'. Ie, Many Fruits exist in many Baskets. There is a field/property on the Fruits table called 'Color'.

What I want to do is get ALL Baskets that contain any fruit of color 'Red'.

What I want is something like:

EntityQuery<Baskets> query = mgr.Baskets.Where(p => p.Fruits.Color == 'Red')

However, the 'Color' property doesn't appear in the intellisense list after 'p => p.Fruits.' Instead, I only get a bunch of methods (eg p.Fruits.Single() or p.Fruits.Contains() instead of what I want which is p.Color). What am I missing here?

Thanks in advance,
Ben


Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 09-Sep-2010 at 5:19pm
Hi Ben,
 
try:
 
var query = mgr.Fruits.Where(f => f.Color == "Red").Select(f => f.Baskets);
 
Regards,
   Silvio.
Back to Top
benmcneill View Drop Down
Newbie
Newbie
Avatar

Joined: 26-Aug-2010
Posts: 11
Post Options Post Options   Quote benmcneill Quote  Post ReplyReply Direct Link To This Post Posted: 09-Sep-2010 at 5:32pm
Hi Silvio

That worked! Thanks for your help, much appreciated.

Regards,
Ben
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down