我正在尝试编写一个linq查询,它将排除具有某个整数ID的子记录的任何记录。在Linq中选择子集
我查询反对看起来像类:
public class Group {
public ICollection<Item> { get; set; } // This is the child collection
}
public class Item {
public int Id { get; set; }
}
我的资料库查询方法是:
public ICollection<Group> Get(int itemId) {
return from c in Set.... // Set is an EF collection of all Groups
}
我想回到所有Groups
没有在他们的Items
收集的Item
有Id
等于itemId
传递给该方法。
不知道如何在Linq中最有效地编写它。
谢谢 - 脑冻结日。 Set来自DbContext,并且没有预加载 - 长话短说,但看起来像是一个泛型基类的结果。 – Graham
@Graham发生了,它仍然在一天的早些时候;-)(至少对我而言) –