Hello I have the next entities:
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; }
}
And in the logic I have:
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;
}
And in my logic of repository I have:
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();
}
But when is going to execute the return line it gives error that can't do the selected part.
Basically what I want is to show everyting from an Area using generic and reflection.