我当前正在使用React Admin框架,它期望与默认Json输出看起来完全不同的格式。如何自定义返回的对象?我已经尝试过使用动作过滤器,但似乎无法正常工作。
我正在使用.net核心Odata v4:http://odata.github.io/
public IActionResult Get(ODataQueryOptions<HC_PortalActivity> options)
{
return Ok(Db.HC_PortalActivity_Collection);
}
{
"@odata.context": "http://localhost:5001/api/$metadata#Hcportalactivity",
"value": [
{
"PortalActivityID": 1,
"AccessSourceID": null,
"ActivityID": null,
"DocumentID": null,
"ForwardedFor": "",
"IPAddress": "::1",
"PortalActivityTypeID": 1,
"PPMessageID": null,
"PrvID": null,
"PtID": 29,
"RecptID_Rep": null,
"RecptTypeID_Rep": null,
"Referrer": "http://localhost:2500/account/login",
"SentTo": "",
"Timestamp": "2017-09-13T14:36:22.727-05:00",
"Url": "http://localhost:2500/account/login",
"PPUserID": 1,
"UserAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36",
"ZUChkSum": 0,
"ZUDate": "2017-09-13T14:36:22.687-05:00",
"ZULogonHisID": 4
}]
}
我需要我的输出看起来像
{
"@odata.context": "http://localhost:5001/api/$metadata#Hcportalactivity",
"data": [
{
"PortalActivityID": 1,
"AccessSourceID": null,
"ActivityID": null,
"DocumentID": null,
"ForwardedFor": "",
"IPAddress": "::1",
"PortalActivityTypeID": 1,
"PPMessageID": null,
"PrvID": null,
"PtID": 29,
"RecptID_Rep": null,
"RecptTypeID_Rep": null,
"Referrer": "http://localhost:2500/account/login",
"SentTo": "",
"Timestamp": "2017-09-13T14:36:22.727-05:00",
"Url": "http://localhost:2500/account/login",
"PPUserID": 1,
"UserAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36",
"ZUChkSum": 0,
"ZUDate": "2017-09-13T14:36:22.687-05:00",
"ZULogonHisID": 4
}],
"total": 2506
}