【问题标题】:Breeze metadata can not pick EF Data AnnotationBreeze 元数据无法选择 EF Data Annotation
【发布时间】:2014-06-15 21:24:31
【问题描述】:

我有一个使用数据注释定义的模型

    public int Id { get; set; }

    [Required, MaxLength(50)]
    public string Title { get; set; }

    [Required, StringLength(2000,MinimumLength = 300)]
    public string Description { get; set; }

    [Required,Range(10,500)]
    public int Budget { get; set; }

我发现微风元数据无法正确获取描述(最小长度)和预算(最小和最大长度范围)的注释。并且由于这种微风验证无法在客户端上正常工作。这是上述模型的微风元数据

property: [
   {
     name: "Id",
     type: "Edm.Int32",
     nullable: "false",
     annotation:StoreGeneratedPattern: "Identity"
   },
   {
     name: "Title",
     type: "Edm.String",
     maxLength: "50",
     fixedLength: "false",
     unicode: "true",
     nullable: "false"
   },
   {
     name: "Description",
     type: "Edm.String",
     maxLength: "300",
     fixedLength: "false",
     unicode: "true",
     nullable: "false"
   },
   {
     name: "Budget",
     type: "Edm.Int32",
     nullable: "false"
   }
]

请推荐

【问题讨论】:

    标签: entity-framework breeze data-annotations


    【解决方案1】:

    目前,breeze 仅支持那些由实体框架 CSDL 元数据捕获的数据注释。这意味着当前只有 [Required]、[MaxLength] 和 [MinLength] 属性。在这些 Breeze 中,仅生成 [Required] 和 [MaxLength] 属性的客户端验证。 (缺少 MinLength 属性是我们的疏忽,将很快修复。)。

    但是,您可以并且应该使用微风将您自己的验证直接添加到客户端模型中。见http://www.breezejs.com/documentation/validation。

    还有一个Breeze User Voice 功能建议。请为它投票。

    【讨论】:

    • 这是一个有用的答案,但该页面的文档似乎没有提到这些。这是一篇较旧的帖子,但最好能更好地指出这一点,因为我目前正在考虑不必为简单的事情制作自定义验证器。很高兴知道这对于 EFCore 是否完全不同
    猜你喜欢
    • 2023-03-18
    • 1970-01-01
    • 2020-07-04
    • 1970-01-01
    • 1970-01-01
    • 2014-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多