diff --git a/实体特性.md b/实体特性.md index 1b78d14..1d9df8c 100644 --- a/实体特性.md +++ b/实体特性.md @@ -64,11 +64,13 @@ class Topic { ```csharp class Topic { - [Column(IsNullable = false), MaxLength(128)] + [MaxLength(128)] public string Title { get; set; } } ``` +MaxLengthAttribute 可以在任意地方定义,因为内部采用反射查找方法。该特性通常定义在 System.ComponentModel.DataAnnotations.MaxLengthAttribute,但如果找不到该类,可自行在项目中定义名称为 MaxLengthAttribute 的特性类,和它的属性 public int Length。 + ## 可空(Nullable) ```csharp