mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 04:18:16 +08:00
- 增加 TableAttribute 特性属性 DisableSyncStructure,当实体对应的是视图时,可使用本功能禁用迁移 #61;
- 增加 FreeSqlBuilder UseEntityPropertyNameConvert() 全局转换实体属性名方法 #60;
This commit is contained in:
@ -17,6 +17,12 @@ namespace FreeSql.DataAnnotations {
|
||||
/// </summary>
|
||||
public string SelectFilter { get; set; }
|
||||
|
||||
internal bool? _DisableSyncStructure;
|
||||
/// <summary>
|
||||
/// 禁用 CodeFirst 同步结构迁移
|
||||
/// </summary>
|
||||
public bool DisableSyncStructure { get => _DisableSyncStructure ?? false; set => _DisableSyncStructure = value; }
|
||||
|
||||
internal ConcurrentDictionary<string, ColumnAttribute> _columns { get; } = new ConcurrentDictionary<string, ColumnAttribute>(StringComparer.CurrentCultureIgnoreCase);
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,14 @@ namespace FreeSql.DataAnnotations {
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 禁用 CodeFirst 同步结构迁移
|
||||
/// </summary>
|
||||
public TableFluent DisableSyncStructure(bool value) {
|
||||
_table.DisableSyncStructure = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ColumnFluent Property(string proto) {
|
||||
if (_properties.ContainsKey(proto) == false) throw new KeyNotFoundException($"找不到属性名 {proto}");
|
||||
var col = _table._columns.GetOrAdd(proto, name => new ColumnAttribute { Name = proto });
|
||||
@ -74,6 +82,14 @@ namespace FreeSql.DataAnnotations {
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 禁用 CodeFirst 同步结构迁移
|
||||
/// </summary>
|
||||
public TableFluent<T> DisableSyncStructure(bool value) {
|
||||
_table.DisableSyncStructure = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ColumnFluent Property<TProto>(Expression<Func<T, TProto>> column) {
|
||||
var proto = (column.Body as MemberExpression)?.Member;
|
||||
if (proto == null) throw new FormatException($"错误的表达式格式 {column}");
|
||||
|
Reference in New Issue
Block a user