AutoQuery 参数在提供时如何工作
How AutoQuery Parameters work when supplied
我一直在查看 servicestack 和文档。关于自动查询文档,预自动查询和 post 自动查询设计如下所示。其中 DTO 不包含参数 "BookedAfter"。据我了解,在非自动查询场景中,Get 将为明显的查询输入选项提供这些参数。对于自动查询,我有几个问题。首先,在我看来,如果您只提供特定参数(而不是让它完全开放),那么只有那些参数才被允许进行过滤(假设 DTO 特定字段)?这是开箱即用的还是需要覆盖自动查询实现?与下面类似,代码使用自定义 "BookedAfter" 参数。是否会覆盖实现,将更具体的参数措辞映射到 DTO 字段查询场景?需要什么才能允许开箱即用的额外查询功能?我无法从文档或社区中找到示例。
[Route("/bookings/search")]
public class SeachBookings : IReturn<SeachBookingsResponse>
{
public DateTime BookedAfter { get; set; }
}
[Route("/bookings/search")]
public class SeachBookings : QueryDb<Booking>
{
public DateTime BookedAfter { get; set; }
}
// Types
public class Booking
{
public int Id { get; set; }
public int ShiftId { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
public int Limit { get; set; }
}
Auto Query parameters simply match the rules in the configured Implicit Conventions, it's irrelevant if the property is defined on the DTO or not unless you restrict it with EnableUntypedQueries=false 在这种情况下,它只会查看来自显式 DTO 属性的约定。
您的 BookedAfter
与 Implicit Convention 匹配:
{"%After%", GreaterThanFormat},
您不限于预先配置的约定,可以add/remove您自己的规则。
我一直在查看 servicestack 和文档。关于自动查询文档,预自动查询和 post 自动查询设计如下所示。其中 DTO 不包含参数 "BookedAfter"。据我了解,在非自动查询场景中,Get 将为明显的查询输入选项提供这些参数。对于自动查询,我有几个问题。首先,在我看来,如果您只提供特定参数(而不是让它完全开放),那么只有那些参数才被允许进行过滤(假设 DTO 特定字段)?这是开箱即用的还是需要覆盖自动查询实现?与下面类似,代码使用自定义 "BookedAfter" 参数。是否会覆盖实现,将更具体的参数措辞映射到 DTO 字段查询场景?需要什么才能允许开箱即用的额外查询功能?我无法从文档或社区中找到示例。
[Route("/bookings/search")]
public class SeachBookings : IReturn<SeachBookingsResponse>
{
public DateTime BookedAfter { get; set; }
}
[Route("/bookings/search")]
public class SeachBookings : QueryDb<Booking>
{
public DateTime BookedAfter { get; set; }
}
// Types
public class Booking
{
public int Id { get; set; }
public int ShiftId { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
public int Limit { get; set; }
}
Auto Query parameters simply match the rules in the configured Implicit Conventions, it's irrelevant if the property is defined on the DTO or not unless you restrict it with EnableUntypedQueries=false 在这种情况下,它只会查看来自显式 DTO 属性的约定。
您的 BookedAfter
与 Implicit Convention 匹配:
{"%After%", GreaterThanFormat},
您不限于预先配置的约定,可以add/remove您自己的规则。