mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 10:08:19 +08:00
Synchronous code
This commit is contained in:
@@ -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);
|
||||
})
|
||||
|
@@ -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
|
||||
|
@@ -124,10 +124,14 @@ namespace SqlSugar
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (item.SqlParameterDbType is Type)
|
||||
if (item.SqlParameterDbType is Type)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (item.SqlParameterDbType is System.Data.DbType dbtype)
|
||||
{
|
||||
paramters.DbType = dbtype;
|
||||
}
|
||||
if (item.IsJson)
|
||||
{
|
||||
paramters.IsJson = true;
|
||||
|
@@ -217,7 +217,7 @@ namespace SqlSugar
|
||||
public virtual object FormatValue(object value)
|
||||
{
|
||||
var N = "N";
|
||||
if (this.Context.CurrentConnectionConfig.DbType == DbType.Sqlite)
|
||||
if (this.Context.CurrentConnectionConfig.DbType == DbType.Sqlite)
|
||||
{
|
||||
N = "";
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@ using System.Linq.Expressions;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
@@ -514,13 +514,17 @@ namespace SqlSugar
|
||||
if (item.SqlParameterDbType is Type)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
var parameter = new SugarParameter(this.SqlBuilder.SqlParameterKeyWord + item.DbColumnName, item.Value, item.PropertyType);
|
||||
if (item.IsJson)
|
||||
{
|
||||
parameter.IsJson = true;
|
||||
SqlBuilder.ChangeJsonType(parameter);
|
||||
}
|
||||
if (item.SqlParameterDbType is System.Data.DbType dbtype)
|
||||
{
|
||||
parameter.DbType = dbtype;
|
||||
}
|
||||
if (item.IsArray)
|
||||
{
|
||||
parameter.IsArray = true;
|
||||
|
Reference in New Issue
Block a user