mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
Custom Guid
This commit is contained in:
parent
1c3b1b5975
commit
c4a71582e3
@ -44,7 +44,14 @@ namespace SqlSugar
|
||||
var isPk = pks.Any(y => y.Equals(item.DbColumnName, StringComparison.CurrentCultureIgnoreCase)) || item.IsPrimarykey;
|
||||
if (isPk && item.PropertyType == UtilConstants.GuidType && item.Value.ObjToString() == Guid.Empty.ToString())
|
||||
{
|
||||
item.Value = Guid.NewGuid();
|
||||
if (StaticConfig.CustomGuidFunc != null)
|
||||
{
|
||||
item.Value = StaticConfig.CustomGuidFunc();
|
||||
}
|
||||
else
|
||||
{
|
||||
item.Value = Guid.NewGuid();
|
||||
}
|
||||
if (InsertObjs.First().GetType().GetProperties().Any(it => it.Name == item.PropertyName))
|
||||
InsertObjs.First().GetType().GetProperties().First(it => it.Name == item.PropertyName).SetValue(InsertObjs.First(), item.Value, null);
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ namespace SqlSugar
|
||||
public const string CodeFirst_BigString = "varcharmax,longtext,text,clob";
|
||||
public static Func<long> CustomSnowFlakeFunc;
|
||||
public static Func<long> CustomSnowFlakeTimeErrorFunc;
|
||||
public static Func<Guid> CustomGuidFunc;
|
||||
|
||||
public static Action<object> CompleteQueryableFunc;
|
||||
public static Action<object> CompleteInsertableFunc;
|
||||
|
Loading…
Reference in New Issue
Block a user