调整初始化租户业务数据Id为空值时自动设置,非空或大于0时按种子设定的Id插入。
This commit is contained in:
parent
18a4aea875
commit
cbc838fe43
@ -479,7 +479,9 @@ public static class SqlSugarSetup
|
||||
{
|
||||
foreach (var sd in seedData)
|
||||
{
|
||||
sd.GetType().GetProperty(nameof(EntityBaseId.Id))!.SetValue(sd, ++tenantId);
|
||||
var id = sd.GetType().GetProperty(nameof(EntityBaseId.Id))!.GetValue(sd, null);
|
||||
if (id != null && (id.ToString() == "0" || string.IsNullOrWhiteSpace(id.ToString())))
|
||||
sd.GetType().GetProperty(nameof(EntityBaseId.Id))!.SetValue(sd, ++tenantId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user