我使用下面的代码返回所有字段。如何使其返回具有匿名类型的列表。
这是我使用的代码:
public List<T> GetList<T>(Expression<Func<T, bool>> where, Func<T, T> select,
params Expression<Func<T, object>>[] navigationProperties) where T : class
{
var database = new ProjectIVModel();
IQueryable<T> dbQuery = database.Set<T>();
foreach (Expression<Func<T,object>> navigationProperty in navigationProperties)
{
dbQuery = dbQuery.Include<T, object>(navigationProperty);
}
if (where != null)
{
dbQuery = dbQuery.Where(where as Expression<Func<T, bool>>);
}
var list = dbQuery
.AsNoTracking()
.Select(select)
.ToList<T>();
return list;
}