我试图从SmartTable中完成当前tableState的asp.net映射。AngularJS SmartTable&ASP.NET映射错误
我使用ASP.NET MVC 5.
我angularjs调用这个样子的:
usersService.getUsers({
start: start,
number: number,
tableState: tableState
}
).then(function(result) {
});
我的queryString参数是这样的:
number:10
start:0
tableState:{"sort":{"predicate":"location","reverse":false},"search":{"predicateObject":{"location":"gfdgd","service":"gfdgd","company":"gd","fullname":"john"}},"pagination":{"start":0,"number":10}}
,当然我试着在asp.net中查询查询信息。我的控制器操作是这样的:
public JsonResult GetUsers(SmartTableRequestModel request)
{
return GetJsonResult(new
{
});
}
而我试图在绑定的模式有以下几种:
public class SmartTableRequestModel
{
public SmartTableQueryModel TableState { get; set; }
public int Number { get; set; } // number is well-binded
public int Start { get; set; } // the start is well-binded too
}
public class SmartTableQueryModel
{
[JsonProperty("sort")]
public SmartTableSortModel Sort { get; set; }
[JsonProperty("search")]
public SmartTableSearchModel Search { get; set; }
[JsonProperty("pagination")]
public SmartTablePaginationModel Pagination { get; set; }
}
public class SmartTableSortModel
{
[JsonProperty("predicate")]
public string Predicate { get; set; }
[JsonProperty("reverse")]
public bool Reverse { get; set; }
}
等等......
,但我没有得到在tableState模型中映射的任何东西。我的SmartTableRequestModel对象中的TableState属性始终为空。
感谢您的帮助下, 勒兹万
我假设你使用的是asp.net MVC。你可以请张贴更多的细节,比如你正在使用什么版本的MVC? –
我更新了我的问题。对不起。我使用ASP.NET MVC 5. –
您是否尝试过使用TypeConverters或模型联编程序?请参阅http://www.asp.net/web-api/overview/formats-and-model-binding/parameter-binding-in-aspnet-web-api – mentat