這是我的問題,現在是1h我正在網上搜索,找不到解決方案。Linq to Entity:添加過濾器到子實體的子實體
我有這些類:
public class User
{
public string Id { get; set; }
public string Name { get; set; }
public virtual ICollection<Tipster> Tipsters { get; set; }
}
public class Tipster
{
public string Id { get; set; }
public string Name { get; set; }
public bool Visible { get; set; }
public virtual ICollection<Bet> Bets { get; set; }
}
public class Bet
{
public string Id { get; set; }
public string Name { get; set; }
public string State { get; set; }
public virtual Tipster Tipster { get; set; }
}
所以用戶有祕技的集合,他的下面,和英超可以推賭注,讓他們有賭注的集合,並且下注只有一個線人創造它。
我工作的WEB API,使用實體框架,我想使用LINQ to實體做到這一點:憑身份證
獲得用戶,其中包括英超的集合,其中可見==真,包括他們的賭注創建但過濾這些,狀態=「掛起」。
我可以過濾英超可見狀態,使用.Any()
或 使用
context.Entry(user).Collection(c => c.Tipsters).Query(...)
但我不知道如何過濾我的子實體(英超)的子實體(賭注)。
'context.Entry(tipster)....'? –
但也看看這裏:https://github.com/jcachat/EntityFramework.DynamicFilters –