Synchronous code

This commit is contained in:
sunkaixuan
2025-07-10 16:52:27 +08:00
parent bd9130a71a
commit 8150e1aa30
5 changed files with 24 additions and 6 deletions

View File

@@ -368,7 +368,7 @@ namespace SqlSugar
var dbColumn = entityInfo.Columns.FirstOrDefault(z => z.PropertyName == it.Key);
if (dbColumn == null&&entityInfo.Discrimator==null)
{
Check.ExceptionEasy($"{entityInfo.EntityName} no SugarIndex[ {it.Key} ] found", $"类{entityInfo.EntityName} 索引特性没找到属性名 {it.Key}");
Check.ExceptionEasy($"{entityInfo.EntityName} no SugarIndex[ {it.Key} ] found", $"类{entityInfo.EntityName} 索引特性没找到 {it.Key}");
}
return new KeyValuePair<string, OrderByType>(dbColumn.DbColumnName, it.Value);
})

View File

@@ -119,6 +119,7 @@ namespace SqlSugar
string tableName = this.Context.EntityMaintenance.GetTableName<T>();
var primaryFields = this.GetPrimaryKeys();
var isSinglePrimaryKey = primaryFields.Count == 1;
var isNvarchar = false;
Check.Exception(primaryFields.IsNullOrEmpty(), string.Format("Table {0} with no primarykey", tableName));
if (isSinglePrimaryKey)
{
@@ -128,6 +129,7 @@ namespace SqlSugar
{
var entityPropertyName = this.Context.EntityMaintenance.GetPropertyName<T>(primaryField);
var columnInfo = EntityInfo.Columns.Single(it => it.PropertyName.Equals(entityPropertyName, StringComparison.CurrentCultureIgnoreCase));
isNvarchar = columnInfo.SqlParameterDbType is System.Data.DbType dbtype && dbtype == System.Data.DbType.String;
var value = columnInfo.PropertyInfo.GetValue(deleteObj, null);
value = UtilMethods.GetConvertValue(value);
if (this.Context.CurrentConnectionConfig?.MoreSettings?.TableEnumIsString!=true&&
@@ -151,7 +153,15 @@ namespace SqlSugar
}
else if (primaryKeyValues.Count < 10000)
{
var inValueString = primaryKeyValues.ToArray().ToJoinSqlInVals();
var inValueString = string.Empty;
if (isNvarchar)
{
inValueString = primaryKeyValues.ToArray().ToJoinSqlInValsByVarchar();
}
else
{
inValueString = primaryKeyValues.ToArray().ToJoinSqlInVals();
}
Where(string.Format(DeleteBuilder.WhereInTemplate, SqlBuilder.GetTranslationColumnName(primaryFields.Single()), inValueString));
}
else

View File

@@ -128,6 +128,10 @@ namespace SqlSugar
{
continue;
}
else if (item.SqlParameterDbType is System.Data.DbType dbtype)
{
paramters.DbType = dbtype;
}
if (item.IsJson)
{
paramters.IsJson = true;

View File

@@ -521,6 +521,10 @@ namespace SqlSugar
parameter.IsJson = true;
SqlBuilder.ChangeJsonType(parameter);
}
if (item.SqlParameterDbType is System.Data.DbType dbtype)
{
parameter.DbType = dbtype;
}
if (item.IsArray)
{
parameter.IsArray = true;