Browse Source

Update InsertNav & UpdateNav

SqlSugar5
sunkaixuan 2 years ago
parent
commit
1127a071b3
  1. 21
      Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/InsertNavProviderManyToMany.cs
  2. 20
      Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/UpdateNavManyToMany.cs

21
Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/InsertNavProviderManyToMany.cs

@ -26,12 +26,11 @@ namespace SqlSugar
.Where(it => it.PropertyName != mappingA.PropertyName)
.Where(it => it.PropertyName != mappingB.PropertyName)
.Where(it => it.IsPrimarykey && !it.IsIdentity && it.OracleSequenceName.IsNullOrEmpty()).FirstOrDefault();
var mappingBizDeleteColumn = mappingEntity.Columns.FirstOrDefault(it =>
it.DbColumnName.EqualCase("isdelete") ||
it.PropertyName.EqualCase("isdelete") ||
it.DbColumnName.EqualCase("isdeleted") ||
it.PropertyName.EqualCase("isdeleted")
);
var mappingOthers = mappingEntity.Columns
.Where(it => it.PropertyName != mappingA.PropertyName)
.Where(it => it.PropertyName != mappingB.PropertyName)
.Where(it => !it.IsIdentity)
.Where(it => !it.IsPrimarykey);
Check.Exception(mappingA == null || mappingB == null, $"Navigate property {name} error ", $"导航属性{name}配置错误");
List<Dictionary<string, object>> mappgingTables = new List<Dictionary<string, object>>();
foreach (var item in parentList)
@ -46,9 +45,15 @@ namespace SqlSugar
Dictionary<string,object> keyValuePairs = new Dictionary<string,object>();
keyValuePairs.Add(mappingA.DbColumnName, parentId);
keyValuePairs.Add(mappingB.DbColumnName, chidId);
if (mappingBizDeleteColumn != null)
if (mappingOthers != null)
{
keyValuePairs.Add(mappingBizDeleteColumn.DbColumnName, UtilMethods.GetDefaultValue(mappingBizDeleteColumn.UnderType));
foreach (var pair in mappingOthers)
{
if (!keyValuePairs.ContainsKey(pair.DbColumnName))
{
keyValuePairs.Add(pair.DbColumnName, UtilMethods.GetDefaultValue(pair.UnderType));
}
}
}
if (mappingPk != null)
{

20
Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/UpdateNavManyToMany.cs

@ -26,11 +26,11 @@ namespace SqlSugar
.Where(it => it.PropertyName != mappingA.PropertyName)
.Where(it => it.PropertyName != mappingB.PropertyName)
.Where(it => it.IsPrimarykey && !it.IsIdentity && it.OracleSequenceName.IsNullOrEmpty()).FirstOrDefault();
var mappingBizDeleteColumn = mappingEntity.Columns.FirstOrDefault(it =>
it.DbColumnName.EqualCase("isdelete") ||
it.PropertyName.EqualCase("isdelete") ||
it.DbColumnName.EqualCase("isdeleted") ||
it.PropertyName.EqualCase("isdeleted"));
var mappingOthers = mappingEntity.Columns
.Where(it => it.PropertyName != mappingA.PropertyName)
.Where(it => it.PropertyName != mappingB.PropertyName)
.Where(it=>!it.IsIdentity)
.Where(it => !it.IsPrimarykey);
Check.Exception(mappingA == null || mappingB == null, $"Navigate property {name} error ", $"导航属性{name}配置错误");
List<Dictionary<string, object>> mappgingTables = new List<Dictionary<string, object>>();
var ids=new List<object>();
@ -57,9 +57,15 @@ namespace SqlSugar
Dictionary<string, object> keyValuePairs = new Dictionary<string, object>();
keyValuePairs.Add(mappingA.DbColumnName, parentId);
keyValuePairs.Add(mappingB.DbColumnName, chidId);
if (mappingBizDeleteColumn != null)
if (mappingOthers != null)
{
keyValuePairs.Add(mappingBizDeleteColumn.DbColumnName, UtilMethods.GetDefaultValue(mappingBizDeleteColumn.UnderType));
foreach (var pair in mappingOthers)
{
if (!keyValuePairs.ContainsKey(pair.DbColumnName))
{
keyValuePairs.Add(pair.DbColumnName, UtilMethods.GetDefaultValue(pair.UnderType));
}
}
}
if (mappingPk != null)
{

Loading…
Cancel
Save