尝试使用 Refit 向控制器发送请求:
[HttpGet("api/users/{userId}/appointments")]
public async Task Get(Guid userId, [FromQuery] FilterRow[] filters = null) {}
使用此方法添加接口:
[Get("/api/users/{userId}/appointments")]
Task<IEnumerable> Get([AliasAs("userId")] Guid userId, [AliasAs("filters")] FilterRow[] filters);
过滤器行:
public class FilterRow
{
public string FieldName { get; set; }
public string FilterValue { get; set; }
public FilterCondition FilterCondition { get; set; }
}
public enum FilterCondition
{
Equals = 0,
LessThan = 1,
LessThanOrEqual = 2,
GreaterThan = 3,
GreaterThanOrEqual = 4,
NotEquals = 5
}
尝试添加 RefitUrlParameterFormatter。但它的功能 Format 来自这个对象的单独值。使用 IFormattable 解决了这个问题,但即使这样它也不能正常工作(控制器没有得到任何值)