Skip to content

Commit 73c8751

Browse files
2881028810
authored andcommitted
- 增加 ColumnAttribute Precision/Scale 设置;
1 parent af15329 commit 73c8751

File tree

9 files changed

+235
-163
lines changed

9 files changed

+235
-163
lines changed

FreeSql.DbContext/EfCoreFluentApi/EfCoreColumnFluent.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,11 @@ public EfCoreColumnFluent IsRowVersion()
5454
//{
5555
// return this;
5656
//}
57+
public EfCoreColumnFluent HasPrecision(int precision, int scale = 0)
58+
{
59+
_cf.Precision(precision, scale);
60+
return this;
61+
}
62+
5763
}
5864
}

FreeSql.DbContext/FreeSql.DbContext.xml

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FreeSql/DataAnnotations/ColumnAttribute.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,16 @@ public class ColumnAttribute : Attribute
104104
/// 注意:如果是 getdate() 这种请可考虑使用 ServerTime,因为它对数据库间作了适配
105105
/// </summary>
106106
public string InsertValueSql { get; set; }
107+
108+
internal int? _Precision;
109+
/// <summary>
110+
/// decimal/numeric 类型的长度
111+
/// </summary>
112+
public int Precision { get => _Precision ?? 0; set => _Precision = value; }
113+
internal int? _Scale;
114+
/// <summary>
115+
/// decimal/numeric 类型的小数位长度
116+
/// </summary>
117+
public int Scale { get => _Scale ?? 0; set => _Scale = value; }
107118
}
108119
}

FreeSql/DataAnnotations/ColumnFluent.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,5 +176,18 @@ public ColumnFluent InsertValueSql(string value)
176176
_column.InsertValueSql = value;
177177
return this;
178178
}
179+
180+
/// <summary>
181+
/// decimal/numeric 类型的长度/小数位长度
182+
/// </summary>
183+
/// <param name="precision">总长度</param>
184+
/// <param name="scale">小数位长度</param>
185+
/// <returns></returns>
186+
public ColumnFluent Precision(int precision, int scale = 0)
187+
{
188+
_column.Precision = precision;
189+
_column.Scale = scale;
190+
return this;
191+
}
179192
}
180193
}

0 commit comments

Comments
 (0)