Monday 15 April 2013

c# - How to use LINQ-to-Entity to query by contained objects -


Assume that I have a list of boxes and you can have many items in one box.

  • box (id)
  • item (id, box id)

I'm trying to create a linq for the unit query I can return all the boxes that contains all the specified items.

  list & lt; Box & gt; FindBoxContainingAllSpecifiedItems (list & lt; int & gt; itemIds) {var q = ctx from box Boxes where ??? }  

Thanks for the help

Depending on the implementation Ask for the box but for the moment that it has a property in which the item IEnumerable & lt; Int & gt; In that case you can see that the item is

  var q = box from ctx.boxes to box where box is used for everyone by using the intext extension method. ITEM Injects (Item ID) ) == Item ID Calculation;  

No comments:

Post a Comment