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