我在vs2013中写了一个mvc5项目
控制器中的方法返回 json
public JsonResult QueryConcens(ConcentratorView concenForQuery)
{
QueryConcentratorsRequest request = new QueryConcentratorsRequest() { ConcenQuery = concenForQuery };
return
Json
(
concenstratorService
.QueryConcentrators(request)
.ConcensView
);
}
模型是
public class ConcentratorView
{
[Required(ErrorMessage="please input id")]
public string ConcentratorID { get; set; }
public string Name { get; set; }
public string Address { get; set; }
}
它返回:
[{"ConcentratorID":"43","Name":"345","Address":"345"},
{"ConcentratorID":"56","Name":"","Address":null},
{"ConcentratorID":"concen_123","Name":"wer","Address":null}]
我希望地址:null 为“”
然后我添加
[DisplayFormat(ConvertEmptyStringToNull = false)]
public string Address { get; set; }
但它返回
[{"ConcentratorID":"43","Name":"345","Address":"345"}]
它丢失了两行
为什么?