这是我的控制器的代码:
public class RegularGrigController : ApiController
{
// GET api/regulargrig
public IEnumerable<string> Get()
{
return EntityHelper.GetEntities().Select(t => t.ModelName());
}
public PageResult<dynamic> Get(string entityName, ODataQueryOptions options)
{
var query = EntityHelper.GetQueryable(entityName).Select("new (Id, SysName)"); // Dynamic queryable
IQueryable results = options.ApplyTo(query); // Exception here
return new PageResult<dynamic>(results as IEnumerable<dynamic>, Request.GetNextPageLink(), Request.GetInlineCount());
}
}
当我尝试拨打这个电话时/api/RegularGrig?entityName=SecurityPrincipal&$orderby=Id
我收到此异常
Type 'System.Object' does not have a property 'Id'
那么,有没有办法对动态数据进行排序/过滤?