我有以下查询,我想使用投影的类名对其进行排序或过滤:
List<CompanyInfo> list = new List<CompanyInfo>();
using (var db = new DbContext())
{
list.AddRange(
db.Companies.Include("Projects")
.Select(row => new CompanyInfo()
{
ProjectCount = (from s in row.Projects
where s.Company.fId == row.fId
select s.pId).Count(),
Id = satir.fId,
})
//.OrderBy("ProjectCount") //<== what I want to do
);
}
我想使用与 ESQL 相同的列ProjectCount
或列动态排序此查询,例如. 由于查询结果是 IQueryable 而不是 ObjectContext 它不起作用。有没有办法做到这一点?Id
.OrderBy("ProjectCount")