I was trying to pass orderby
clause as a parameter:
public IList<SomeType> GetData(Expression<Func<Customer, object>> order)
{
if (order==null)
{
order = x => x.PrintOrder ;
}
var list = (from c in this.dbContext.Customer
where c.Type==1
orderby order
select new {c.Name }).ToList();
return list;
}
But this throws an error:
System.InvalidOperationException: could not be translated.
Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList'