- 补充 nuget 包增加 xmlDoc 编译;

- 调整 Column.Unique 定义规则,解决同一属性不可配置多次的问题;
This commit is contained in:
28810
2019-04-28 17:43:42 +08:00
parent d49be984bd
commit 163fe89bd4
10 changed files with 50 additions and 28 deletions

View File

@ -1,4 +1,5 @@
using System;
using System.Linq;
namespace FreeSql.DataAnnotations {
public class ColumnAttribute : Attribute {
@ -38,10 +39,30 @@ namespace FreeSql.DataAnnotations {
/// </summary>
public bool IsVersion { get => _IsVersion ?? false; set => _IsVersion = value; }
internal string[] _Uniques;
/// <summary>
/// 唯一键,多个属性指定相同的标识,代表联合键
/// 唯一键,多个属性指定相同的标识,代表联合键;可使用逗号分割多个 UniqueKey 名。
/// </summary>
public string Unique { get; set; }
public string Unique {
get => _Uniques == null ? null : string.Join(", ", _Uniques);
set {
if (string.IsNullOrEmpty(value)) {
_Uniques = null;
return;
}
var val = value?.Trim(' ', '\t', ',');
if (string.IsNullOrEmpty(val)) {
_Uniques = null;
return;
}
var arr = val.Split(',').Select(a => a.Trim(' ', '\t').Trim()).Where(a => !string.IsNullOrEmpty(a)).ToArray();
if (arr.Any() == false) {
_Uniques = null;
return;
}
_Uniques = arr;
}
}
/// <summary>
/// 数据库默认值
/// </summary>

View File

@ -66,7 +66,7 @@ namespace FreeSql.DataAnnotations {
return this;
}
/// <summary>
/// 唯一键,多个属性指定相同的标识,代表联合键
/// 唯一键,多个属性指定相同的标识,代表联合键;可使用逗号分割多个 UniqueKey 名。
/// </summary>
/// <param name="value">标识</param>
/// <returns></returns>