I have the following query which I want to sort or filter using projected class names:
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
);
}
I want to dynamically order this query using ProjectCount
or Id
columns same as ESQL, like .OrderBy("ProjectCount")
. Since the query result is IQueryable instead of ObjectContext it doesn't work. Is there a way to do this?
Thanks for the replies, I used helper extension methods: