mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-21 02:58:05 +08:00
optimization
This commit is contained in:
@@ -67,6 +67,8 @@ namespace OrmTest.UnitTest
|
||||
{
|
||||
throw new Exception("DataTest Error");
|
||||
}
|
||||
|
||||
db.Insertable(new DataTestInfo2() { }).ExecuteCommand();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,6 +35,16 @@ namespace SqlSugar
|
||||
#region Core
|
||||
public virtual int ExecuteCommand()
|
||||
{
|
||||
if (InsertBuilder.DbColumnInfoList.HasValue())
|
||||
{
|
||||
var pks = GetPrimaryKeys();
|
||||
foreach (var item in InsertBuilder.DbColumnInfoList)
|
||||
{
|
||||
if (item.IsPrimarykey==true||(pks.Any(y=>y.Equals(item.DbColumnName,StringComparison.CurrentCultureIgnoreCase)))&&item.PropertyType == UtilConstants.GuidType&&item.Value.ObjToString()==Guid.Empty.ToString()) {
|
||||
item.Value = Guid.NewGuid();
|
||||
}
|
||||
}
|
||||
}
|
||||
InsertBuilder.IsReturnIdentity = false;
|
||||
PreToSql();
|
||||
AutoRemoveDataCache();
|
||||
@@ -440,7 +450,8 @@ namespace SqlSugar
|
||||
if (this.Context.Ado.DiffLogEvent != null)
|
||||
this.Context.Ado.DiffLogEvent(diffModel);
|
||||
}
|
||||
if (this.RemoveCacheFunc != null) {
|
||||
if (this.RemoveCacheFunc != null)
|
||||
{
|
||||
this.RemoveCacheFunc();
|
||||
}
|
||||
}
|
||||
@@ -467,8 +478,10 @@ namespace SqlSugar
|
||||
var fieldName = GetIdentityKeys().Last();
|
||||
cons.Add(new ConditionalModel() { ConditionalType = ConditionalType.Equal, FieldName = fieldName, FieldValue = identity.ToString() });
|
||||
}
|
||||
else {
|
||||
foreach(var item in this.EntityInfo.Columns.Where(it => it.IsIgnore == false&&GetPrimaryKeys().Any(pk=>pk.Equals(it.DbColumnName,StringComparison.CurrentCultureIgnoreCase)))) {
|
||||
else
|
||||
{
|
||||
foreach (var item in this.EntityInfo.Columns.Where(it => it.IsIgnore == false && GetPrimaryKeys().Any(pk => pk.Equals(it.DbColumnName, StringComparison.CurrentCultureIgnoreCase))))
|
||||
{
|
||||
var fielddName = item.DbColumnName;
|
||||
var fieldValue = this.EntityInfo.Columns.FirstOrDefault(it => it.PropertyName == item.PropertyName).PropertyInfo.GetValue(this.InsertObjs.Last(), null).ObjToString();
|
||||
cons.Add(new ConditionalModel() { ConditionalType = ConditionalType.Equal, FieldName = fielddName, FieldValue = fieldValue });
|
||||
@@ -499,7 +512,8 @@ namespace SqlSugar
|
||||
}
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
DiffLogTableInfo diffTable = new DiffLogTableInfo();
|
||||
diffTable.TableName = this.EntityInfo.DbTableName;
|
||||
diffTable.TableDescription = this.EntityInfo.TableDescription;
|
||||
|
Reference in New Issue
Block a user