将嵌套对象发送到asp.net core Get方法

Rém*_*émy 5 c# asp.net-core asp.net-core-webapi

我有以下模型对象

[DataContract]
public class Filter
{
    [DataMember (Name ="start")]
    public int Start { get; set; }

    [DataMember (Name="rows")]
    public int Rows { get; set; }

    [DataMember(Name = "geoloc")]
    public GeoLocationModel GeoLocation { get; set; }

}

[DataContract]
public class GeoLocationModel
{
    [DataMember(Name = "lat")]
    public double Latitude { get; set; }

    [DataMember(Name = "lng")]
    public double Longitude { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

以及以下动作

    [HttpGet]
    public async Task GetCities([FromQuery]Models.Filters.Filter filters)
    {
        //some code
    }
Run Code Online (Sandbox Code Playgroud)

当我使用以下查询调用操作时(由 axios 生成的查询):

   /api/cities/?start=0&rows=5&geoloc=%7B%22lat%22:44,%22lng%22:3%7D
Run Code Online (Sandbox Code Playgroud)

参数 Start 和 Rows 已正确填写,但 GeoLoc 为空。

我需要如何格式化查询以满足FromQuery属性?

Ren*_*ena 3

你可以尝试这样的网址:/api/cities?start=4&rows=5&geoloc.Latitude=4&geoloc.Longitude=3