I am trying to Order by a query using the following efcore query
Getting the PropertyInfo for the column which needs to be orderedBy using this below
var propertyInfo = typeof(TableVM).GetProperty("Type");
The EfCore Query
db.Table
**//LinkKit Extension Method**
.AsExpandable()
.Where(whereClause)
.Select(m => new TableVM
{
id= m.Id,
name = m.Name,
description = m.Description,
type = m.Type,
status = m.Status
})
**// Conversion of the OrderBy fails, which throws an exception saying it can't convert it into Linq query.**
.OrderBy(x => propertyInfo.GetValue(x, null))
.Skip(skip)
.Take(take)
.ToList();
C# - code to order by a property using the property name as a string
This works in EfCore 2.
Tested with removing the LinqKit extension in EfCore 3.1.3, it throws error only for OrderBy stating it can't convert it into Linq
Am I doing any mistake in the EfCore Query? Thanks in advance