cri..." />

Fetching items which has a specific set of child elements (advanced query - possible?)?

This should work for you: string criteria = new { "Car", "Ford", "Offroad" }; var items = from I in db. Item let wantedMetas = db.Meta. Where(m => criteria.

Contains(m. Name)) let metas = i.ItemMeta. Select(im => im.

Meta) where wantedMetas. All(m => metas. Contains(m)) select I Basically it compares the "wanted" metas against each item's metas, and selects the items which have all the wanted metas (or more).

This should work for you: string criteria = new { "Car", "Ford", "Offroad" }; var items = from I in db. Item let wantedMetas = db.Meta. Where(m => criteria.

Contains(m. Name)) let metas = i.ItemMeta. Select(im => im.

Meta) where wantedMetas. All(m => metas. Contains(m)) select i; Basically it compares the "wanted" metas against each item's metas, and selects the items which have all the wanted metas (or more).

This brings back anything that matchs any of the meta criteria, and then filters it down to only things that match all the criteria. (also, keep in mind that you'll need to have your relationship defined in your datacontext). Let us know if you need clarification.

Var db = new YourDataContext(); var possibleItems = (from m in db. Metas where select m.ItemMetas. Item); var items = possibleItems.

GroupBy(y=>y). Where(x=>x.Count() == criteriaCount). Select(x=>x.

Key).

Thank you, but I would like, to the fulles possible extent, try to avoid returning data to the client which will then be discarded, i. E client side filtration is something I'd like to avoid so I do not have to use more bandwidth than necessary – TheCodeJunkie Oct 31 '08 at 6:38 I broke the query into two sections, "possibleitems" and "items" but in reality, the DB is never hit until after you start enumerating "items" - only the exact things you want are hit. If you're using Linq, you should know about "Deferred Execution" – Andrew Theken Feb 14 '09 at 14:05.

You could filter the items by counting the filtered metas. List metaList = new List() { "Car", "Ford", "Offroad" }; int metaListCount = metaList. Count; List result = db.

Items . Where(i => metaListCount == i.ItemMeta. Meta .

Where(m => metaList. Contains(m. Name)) .Count() ) .ToList(); Be aware that there is an upper limit for this in-memory collection .

Contains imposed by SqlServer's parameter limit (it's either ~200 or ~2000, I can never remember).

Here are a few items where help would be welcome. The SendKeys function is based on the Delphi sourcecode published by Al Williams in Dr.Dobbs . Copyright (c) 1998-2002 Ernesto Guisado, (c) 2004 Dennis K.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions