我試圖做的部分如下:LINQ查詢 - 獲取父實體,其中至少有一個孩子實體名單
class Account
{
public virtual Ilist<Manager> Managers{get;set;}
}
class Manager
{
public virtual Ilist<Account> Accounts{get;set;}
}
...
private void Filter()
{
// List of Accounts
// Each Account has one or more Managers
// Each Manager has one or more Accounts
Ilist<Manager> FilteredManagers = new List<Manager>();
FilteredManagers .Add(new Manager(1));
FilteredManagers .Add(new Manager(2));
etc.
//I tried something like
var _Accounts = from a in Accounts
where FilteredManagers.Contains(a.Managers)
select a
//but this didn't compile
}
我想運行在賬戶查詢返回所有賬戶與一個或更多的管理人員也在FilteredManagers 我認爲這是一種很不錯的方式,但我對編程相當陌生。
怎麼樣:其中FilteredManagers.Contains(a.Managers.Any()) – iceheaven31