Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 为不可为null的int传入null将在Delta中消失<;T>;_C#_Asp.net_Rest_Asp.net Web Api - Fatal编程技术网

C# 为不可为null的int传入null将在Delta中消失<;T>;

C# 为不可为null的int传入null将在Delta中消失<;T>;,c#,asp.net,rest,asp.net-web-api,C#,Asp.net,Rest,Asp.net Web Api,我有一个更新实体的典型端点 public IHttpActionResult Patch([FromODataUri] int key, Delta<Individual> patch) 响应 { "error": { "code": "", "message": "Request contains validation errors.", "details": [ {

我有一个更新实体的典型端点

public IHttpActionResult Patch([FromODataUri] int key, Delta<Individual> patch)
响应

{
    "error": {
        "code": "",
        "message": "Request contains validation errors.",
        "details": [
            {
                "target": "patch",
                "message": "",
                "innerError": {
                    "message": "Cannot convert the literal '' to the expected type 'Edm.Int32'."
                }
            }
        ]
    }
}
{
    "error": {
        "code": "",
        "message": "Request contains validation errors.",
        "details": [
            {
                "target": "patch",
                "message": "",
                "innerError": {
                    "message": "Cannot convert null to the expected type 'Edm.Int32'."
                }
            }
        ]
    }
}
但是,当我传入null时,它不会给出验证错误,并且Delta对象不会将其列为已更改的属性

请求

{ 
  "statusId": ""
}
{ 
  "statusId": null
}
预期响应

{
    "error": {
        "code": "",
        "message": "Request contains validation errors.",
        "details": [
            {
                "target": "patch",
                "message": "",
                "innerError": {
                    "message": "Cannot convert the literal '' to the expected type 'Edm.Int32'."
                }
            }
        ]
    }
}
{
    "error": {
        "code": "",
        "message": "Request contains validation errors.",
        "details": [
            {
                "target": "patch",
                "message": "",
                "innerError": {
                    "message": "Cannot convert null to the expected type 'Edm.Int32'."
                }
            }
        ]
    }
}
我们希望当他们为不可为null的字段传入null时,能够验证并返回错误,而不仅仅是默默地忽略错误


如何完成此任务?

标记为“必需”。