WebAPI 中 ODATA 操作中的字典参数
Dictionary parameter in ODATA action in WebAPI
有没有办法将字典类型的集合参数传递给 ODATA 操作? JSON 有效载荷将如下所示:
{
"MyParameter": [
{
"property1": "A",
"property2": "B"
},
{
"otherProperty": 1,
"property2": "C"
}
]
}
你必须先定义一个参数class
public class MyActionParameters
{
public IEnumerable<Dictionary<string, object>> MyParameter
{
}
}
然后在您的控制器中
[HttpPost]
[Route("MyAction")]
public async Task<IHttpActionResult> Sync([FromBody] MyActionParameters parameters)
{
}
有没有办法将字典类型的集合参数传递给 ODATA 操作? JSON 有效载荷将如下所示:
{
"MyParameter": [
{
"property1": "A",
"property2": "B"
},
{
"otherProperty": 1,
"property2": "C"
}
]
}
你必须先定义一个参数class
public class MyActionParameters
{
public IEnumerable<Dictionary<string, object>> MyParameter
{
}
}
然后在您的控制器中
[HttpPost]
[Route("MyAction")]
public async Task<IHttpActionResult> Sync([FromBody] MyActionParameters parameters)
{
}