1
    public static IQueryable<Institution> WithFunds(this IQueryable<Institution> query, IEnumerable<Fund> allowedFunds)
    {
        return query.
    }

我希望查询返回所有机构,该机构在机构.基金的“允许基金”列表中提供任何基金。请帮忙。

我的班级层次结构是这样的。

   public partial class Institution 
   {
   public int Id { get; set; }
   public virtual ICollection<Fund> Funds { get; set; }
   }

   public partial class Fund
   {
   public int Id { get; set; }
   public virtual Institution Institution { get; set; }
   }
4

1 回答 1

1

您可以使用Contains查询:

Fund[] funds = allowedFunds.ToArray();
return query.Where(x => x.Funds.Any(f => funds.Contains(f)));
于 2012-04-08T05:23:49.417 回答