mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 18:22:23 +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);
|
var dbColumn = entityInfo.Columns.FirstOrDefault(z => z.PropertyName == it.Key);
|
||||||
if (dbColumn == null&&entityInfo.Discrimator==null)
|
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);
|
return new KeyValuePair<string, OrderByType>(dbColumn.DbColumnName, it.Value);
|
||||||
})
|
})
|
||||||
|
@@ -119,6 +119,7 @@ namespace SqlSugar
|
|||||||
string tableName = this.Context.EntityMaintenance.GetTableName<T>();
|
string tableName = this.Context.EntityMaintenance.GetTableName<T>();
|
||||||
var primaryFields = this.GetPrimaryKeys();
|
var primaryFields = this.GetPrimaryKeys();
|
||||||
var isSinglePrimaryKey = primaryFields.Count == 1;
|
var isSinglePrimaryKey = primaryFields.Count == 1;
|
||||||
|
var isNvarchar = false;
|
||||||
Check.Exception(primaryFields.IsNullOrEmpty(), string.Format("Table {0} with no primarykey", tableName));
|
Check.Exception(primaryFields.IsNullOrEmpty(), string.Format("Table {0} with no primarykey", tableName));
|
||||||
if (isSinglePrimaryKey)
|
if (isSinglePrimaryKey)
|
||||||
{
|
{
|
||||||
@@ -128,6 +129,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
var entityPropertyName = this.Context.EntityMaintenance.GetPropertyName<T>(primaryField);
|
var entityPropertyName = this.Context.EntityMaintenance.GetPropertyName<T>(primaryField);
|
||||||
var columnInfo = EntityInfo.Columns.Single(it => it.PropertyName.Equals(entityPropertyName, StringComparison.CurrentCultureIgnoreCase));
|
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);
|
var value = columnInfo.PropertyInfo.GetValue(deleteObj, null);
|
||||||
value = UtilMethods.GetConvertValue(value);
|
value = UtilMethods.GetConvertValue(value);
|
||||||
if (this.Context.CurrentConnectionConfig?.MoreSettings?.TableEnumIsString!=true&&
|
if (this.Context.CurrentConnectionConfig?.MoreSettings?.TableEnumIsString!=true&&
|
||||||
@@ -151,7 +153,15 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
else if (primaryKeyValues.Count < 10000)
|
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));
|
Where(string.Format(DeleteBuilder.WhereInTemplate, SqlBuilder.GetTranslationColumnName(primaryFields.Single()), inValueString));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -124,10 +124,14 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (item.SqlParameterDbType is Type)
|
if (item.SqlParameterDbType is Type)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
else if (item.SqlParameterDbType is System.Data.DbType dbtype)
|
||||||
|
{
|
||||||
|
paramters.DbType = dbtype;
|
||||||
|
}
|
||||||
if (item.IsJson)
|
if (item.IsJson)
|
||||||
{
|
{
|
||||||
paramters.IsJson = true;
|
paramters.IsJson = true;
|
||||||
|
@@ -217,7 +217,7 @@ namespace SqlSugar
|
|||||||
public virtual object FormatValue(object value)
|
public virtual object FormatValue(object value)
|
||||||
{
|
{
|
||||||
var N = "N";
|
var N = "N";
|
||||||
if (this.Context.CurrentConnectionConfig.DbType == DbType.Sqlite)
|
if (this.Context.CurrentConnectionConfig.DbType == DbType.Sqlite)
|
||||||
{
|
{
|
||||||
N = "";
|
N = "";
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ using System.Linq.Expressions;
|
|||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
{
|
{
|
||||||
@@ -514,13 +514,17 @@ namespace SqlSugar
|
|||||||
if (item.SqlParameterDbType is Type)
|
if (item.SqlParameterDbType is Type)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var parameter = new SugarParameter(this.SqlBuilder.SqlParameterKeyWord + item.DbColumnName, item.Value, item.PropertyType);
|
var parameter = new SugarParameter(this.SqlBuilder.SqlParameterKeyWord + item.DbColumnName, item.Value, item.PropertyType);
|
||||||
if (item.IsJson)
|
if (item.IsJson)
|
||||||
{
|
{
|
||||||
parameter.IsJson = true;
|
parameter.IsJson = true;
|
||||||
SqlBuilder.ChangeJsonType(parameter);
|
SqlBuilder.ChangeJsonType(parameter);
|
||||||
}
|
}
|
||||||
|
if (item.SqlParameterDbType is System.Data.DbType dbtype)
|
||||||
|
{
|
||||||
|
parameter.DbType = dbtype;
|
||||||
|
}
|
||||||
if (item.IsArray)
|
if (item.IsArray)
|
||||||
{
|
{
|
||||||
parameter.IsArray = true;
|
parameter.IsArray = true;
|
||||||
|
Reference in New Issue
Block a user