【问题标题】:DataAnnotations missing attributesDataAnnotations 缺少属性
【发布时间】:2013-09-19 15:02:31
【问题描述】:

我在文件顶部有using System.ComponentModel.DataAnnotations;,但基本上我拥有的唯一属性是[DisplayName][Readonly]。甚至[Display(Name...] 也不存在。我错过了什么?

【问题讨论】:

  • 又是什么问题?
  • DataAnnotations[Required] 通常附带的属性不存在?
  • Required 就在这里:msdn.microsoft.com/de-de/library/…...
  • DisplayNameSystem.ComponentModel (link) 的一部分。
  • @idlackage 确保您对 System.dll 和 System.ComponentModel.DataAnnotations.dll 都有程序集引用

标签: c# asp.net-mvc-4 .net-4.5 data-annotations


【解决方案1】:

Resharper 等工具允许您分析代码文件中的 using 语句。

如果您发现不需要using 语句,请将其删除。

【讨论】:

    【解决方案2】:

    使用以下命名空间:

    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-26
      • 2023-04-03
      • 2012-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多