有人知道如何自定义 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"}
]
}