服务栈 [必需] 注解不起作用

Service Stack [Required] Annotation does not work

我有一个模型,我在上面添加了一个必需的注释,但它没有任何作用。它不会抛出任何错误。我是否必须向配置添加一些内容以确保触发注释。

using System.ComponentModel.DataAnnotations;

 [ApiMember(Description = "The student ID to lookup", IsRequired = true, ParameterType = "form")]
 [Required]
 public int? StudentId { get; set; }

[Required] 属性可用于 OrmLite 数据模型来注释不可为 null 的字段,但它对 ServiceStack DTO 没有任何影响。

要验证 DTO,建议使用 built-in Fluent Validation support