你好,我有下一个实体:
public class Area
{
public ICollection<Indicator> Indicators { get; set; }
}
public class Indicator
{
public Operator GreenCondition { get; set; }
}
public class Operator
{
public string Name { get; set; }
}
按照逻辑,我有:
public Area Get(int id)
{
List<Expression<Func<Area, object>>> includes = new List<Expression<Func<Area, object>>>();
includes.Add(x => x.Indicators);
includes.Add(x => x.Indicators.Select(i => i.GreenCondition));
includes.Add(x => x.Managers);
Area area = repAreas.Get(includes, a => a.Id == id && a.Active);
return area;
}
按照我的存储库逻辑,我有:
public T Get(IEnumerable<Expression<Func<T, object>>> includes, Func<T, bool> predicate)
{
var query = _objectSet.AsQueryable<T>();
if(!(includes is null))
{
query = includes.Aggregate(query, (current, include) => current.Include(include));
}
return query.Where(predicate).FirstOrDefault();
}
但是当执行返回行时,它会给出无法执行所选部分的错误。
基本上,我想要使用泛型和反射来显示Area中的所有内容。