任何人都知道如何自定义asp.net webapi返回的名称?我真的很有兴趣将“odata.count”更改为“odata-count” - 点正在弄乱Infragistics IgniteUI控件。
示例网址:http://localhost/odata/users?$inlineCount=allpages&$top=10
示例oData:
{
"odata.metadata":"http://mydomain/odata/$metadata#Users",
"odata.count":"3",
"value":[
{"FirstName":"Alan","MiddleName":"A.","LastName":"Arlington"},
{"FirstName":"Brad","MiddleName":"B.","LastName":"Boston"},
{"FirstName":"Dirk","MiddleName":"J.","LastName":"Watkins"}
]
}
我还可以将所有oData元数据放在一个单独的顶级对象中,如:
{
"odata":{
"metadata":"http://mydomain/odata/$metadata#Users",
"count":"3",
},
"value":[
{"FirstName":"Alan","MiddleName":"A.","LastName":"Arlington"},
{"FirstName":"Brad","MiddleName":"B.","LastName":"Boston"},
{"FirstName":"Dirk","MiddleName":"J.","LastName":"Watkins"}
]
}
答案 0 :(得分:2)
OData协议defines以JSON格式表示OData请求和响应的标准表示。 odata.count之类的元数据键名称由规范定义,不能配置为与标准客户端的可操作性。
简而言之,您无法自定义这些名称。