Browse Source

Synchronization code

pull/24/head
sunkaixuan 2 years ago
parent
commit
86e1cef79a
  1. 4
      Src/Asp.NetCore2/SqlSugar/Abstract/ExecuteNavProvider/InsertNavProviderHelper.cs
  2. 1
      Src/Asp.NetCore2/SqlSugar/Utilities/UtilMethods.cs

4
Src/Asp.NetCore2/SqlSugar/Abstract/ExecuteNavProvider/InsertNavProviderHelper.cs

@ -94,6 +94,10 @@ namespace SqlSugar
private void InsertDatas<TChild>(List<TChild> children, EntityColumnInfo pkColumn, EntityColumnInfo NavColumn=null) where TChild : class, new() private void InsertDatas<TChild>(List<TChild> children, EntityColumnInfo pkColumn, EntityColumnInfo NavColumn=null) where TChild : class, new()
{ {
children = children.Distinct().ToList(); children = children.Distinct().ToList();
if (pkColumn == null)
{
Check.ExceptionEasy($"{typeof(TChild).Name} need primary key ", $"{typeof(TChild).Name}需要主键");
}
var x = this._Context.Storageable(children).WhereColumns(new string[] { pkColumn.PropertyName }).ToStorage(); var x = this._Context.Storageable(children).WhereColumns(new string[] { pkColumn.PropertyName }).ToStorage();
var insertData = children = x.InsertList.Select(it => it.Item).ToList(); var insertData = children = x.InsertList.Select(it => it.Item).ToList();
var IsNoExistsNoInsert = _navOptions != null && _navOptions.OneToManyIfExistsNoInsert == true; var IsNoExistsNoInsert = _navOptions != null && _navOptions.OneToManyIfExistsNoInsert == true;

1
Src/Asp.NetCore2/SqlSugar/Utilities/UtilMethods.cs

@ -370,6 +370,7 @@ namespace SqlSugar
else else
return Enum.ToObject(type, value); return Enum.ToObject(type, value);
} }
if (value is string && type == typeof(Guid?)) return value.IsNullOrEmpty() ? null : (Guid?)new Guid(value as string);
if (!type.IsInterface && type.IsGenericType) if (!type.IsInterface && type.IsGenericType)
{ {
Type innerType = type.GetGenericArguments()[0]; Type innerType = type.GetGenericArguments()[0];

Loading…
Cancel
Save