vil*_*sky 2 .net c# asp.net-mvc odata asp.net-web-api
我的数据层没有公开IQueryable.我仍然希望能够对数据进行排序.我的API具有这样的功能,但我需要确定需要排序的内容.假设我配置了模型,例如:
ODataModelBuilder modelBuilder = new ODataConventionModelBuilder();
modelBuilder.EntitySet<Airline>("Airlines");
modelBuilder.EntitySet<FlightLeg>("Legs");
Run Code Online (Sandbox Code Playgroud)
现在在控制器中我可以获得OdataQueryOptions并找出请求的edm模型类型/属性排序.我需要完成的是获取用于配置的CLR类型的属性的PropertyInfo,例如Airline.PlaneModel.
我很难通过API获取元数据,但没有成功.请帮忙.
在控制器中尝试此代码段:
//using Microsoft.Data.Edm
IEdmModel edmModel = Request.ODataProperties().Model;
ClrTypeAnnotation annotation = edmModel.GetAnnotationValue<ClrTypeAnnotation>(edmSchemaType);
if (annotation != null)
{
return annotation.ClrType;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1624 次 |
| 最近记录: |