I get this compile error
The type 'TEntiy' must be a reference type in order to use it a parameter 'TEntity' in the generic type or method 'DbSet'.
When used in this method:
private IQueryable<TEntity> Search<Expression<Func<TEntity, bool>> predicate, params Expression<Func<TEntity, object>>[] include)
{
var dbSet = dataContext.Set<TEntity>();
var set = include.Aggregate<Expression<Func<TEntity, object>>, IQueryable<TEntity>>
(dbSet, (current, expression) => current.Include(expression));
return set.Where(predicate);
}
Is there a way to fix this problem?
The DbSet<TEntity> type requires its type argument to be a reference type. You can ensure this is the case by adding a generic type constraint:
private IQueryable<TEntity> Search<TEntity>(...) where TEntity : class
{
...
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments