I'm migrating my code from EF6 to EF Core and in my generic repository I have the following method:
public virtual IQueryable<T> Get(Expression<Func<T, bool>> predicate, params Expression<Func<T, object>>[] include)
{
try
{
if (include.Any())
{
var set = include.Aggregate<Expression<Func<T, object>>, IQueryable<T>>
(dbSet, (current, expression) => current.Include(expression));
return set.Where(predicate).AsNoTracking<T>();
}
return dbSet.Where(predicate).AsNoTracking<T>();
}
catch (Exception ex)
{
throw new DatabaseException(ex);
}
}
And in the concrete repositories:
public override User Get(Expression<Func<User, bool>> predicate)
{
return base.Get(predicate,
x => x.Rights.Select(g => g.Right);
}
In EF6 this was working perfectly. But now in EF Core I'm getting the following error:
How can I get this method to work again?