Synchronous code

This commit is contained in:
sunkaixuan
2025-05-09 15:40:07 +08:00
parent 6d4947d6f3
commit 3ce6d17d9f
5 changed files with 13 additions and 8 deletions

View File

@@ -794,7 +794,7 @@ namespace SqlSugar
var columns = entityInfo.Columns.Where(it => it.IsIgnore == false).ToList();
foreach (var item in columns)
{
if (item.DefaultValue.HasValue())
if (item.DefaultValue!=null)
{
if (!IsAnyDefaultValue(entityInfo.DbTableName,item.DbColumnName,dbColumns))
{

View File

@@ -42,12 +42,16 @@ namespace SqlSugar
foreach (var item in InsertBuilder.DbColumnInfoList)
{
var isPk = pks.Any(y => y.Equals(item.DbColumnName, StringComparison.CurrentCultureIgnoreCase)) || item.IsPrimarykey;
if (isPk && item.PropertyType == UtilConstants.GuidType && item.Value.ObjToString() == Guid.Empty.ToString())
if (isPk && item.PropertyType == UtilConstants.GuidType && item.Value is Guid guid && guid == Guid.Empty)
{
if (StaticConfig.CustomGuidFunc != null)
{
item.Value = StaticConfig.CustomGuidFunc();
}
else if (StaticConfig.CustomGuidByValueFunc != null&& item.Value is Guid guidValue)
{
item.Value = StaticConfig.CustomGuidByValueFunc(guidValue);
}
else
{
item.Value = Guid.NewGuid();

View File

@@ -881,20 +881,20 @@ namespace SqlSugar
{
return UtilMethods.CountSubstringOccurrences(sql,"WHERE")>1;
}
private bool IsCorrectErrorSqlParameterName()
protected bool IsCorrectErrorSqlParameterName()
{
return this.Context?.CurrentConnectionConfig?.MoreSettings?.IsCorrectErrorSqlParameterName == true;
}
private void ThrowUpdateByExpression()
protected void ThrowUpdateByExpression()
{
Check.Exception(UpdateParameterIsNull == true, ErrorMessage.GetThrowMessage(" no support UpdateColumns and WhereColumns", "根据表达式更新 db.Updateable<T>() 禁止使用 UpdateColumns和WhereColumns,你可以使用 SetColumns Where 等。更新分为2种方式 1.根据表达式更新 2.根据实体或者集合更新, 具体用法请查看文档 "));
}
private void ThrowUpdateByObject()
protected void ThrowUpdateByObject()
{
Check.Exception(UpdateParameterIsNull == false, ErrorMessage.GetThrowMessage(" no support SetColumns and Where", "根据对像更新 db.Updateabe(对象) 禁止使用 SetColumns和Where ,你可以使用WhereColumns 和 UpdateColumns。 更新分为2种方式 1.根据表达式更新 2.根据实体或者集合更新 具体用法请查看文档 "));
}
private void ThrowUpdateByExpressionByMesage(string message)
protected void ThrowUpdateByExpressionByMesage(string message)
{
Check.Exception(UpdateParameterIsNull == true, ErrorMessage.GetThrowMessage(" no support "+ message, "根据表达式更新 db.Updateable<T>()禁止使用 " + message+"。 更新分为2种方式 1.根据表达式更新 2.根据实体或者集合更新 具体用法请查看文档 "));
}

View File

@@ -784,7 +784,7 @@ namespace SqlSugar
}
public IUpdateable<T> SetColumns(Expression<Func<T, T>> columns, bool appendColumnsByDataFilter)
public virtual IUpdateable<T> SetColumns(Expression<Func<T, T>> columns, bool appendColumnsByDataFilter)
{
ThrowUpdateByObject();
var expResult = UpdateBuilder.GetExpressionValue(columns, ResolveExpressType.Update);
@@ -843,7 +843,7 @@ namespace SqlSugar
AppendSets();
return this;
}
public IUpdateable<T> SetColumns(Expression<Func<T, bool>> columns)
public virtual IUpdateable<T> SetColumns(Expression<Func<T, bool>> columns)
{
ThrowUpdateByObject();

View File

@@ -21,6 +21,7 @@ namespace SqlSugar
public static Func<long> CustomSnowFlakeFunc;
public static Func<long> CustomSnowFlakeTimeErrorFunc;
public static Func<Guid> CustomGuidFunc;
public static Func<Guid,Guid> CustomGuidByValueFunc;
public static Action<object> CompleteQueryableFunc;
public static Action<object> CompleteInsertableFunc;