mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 18:22:23 +08:00
Update core
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
<package >
|
<package >
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>sqlSugar</id>
|
<id>sqlSugar</id>
|
||||||
<version>5.0.0.6</version>
|
<version>5.0.0.7</version>
|
||||||
<title>SqlSugar 5.0+ .Net Framework 4.5+ , SqlSugar 4.0+ .Net Framework 4.0+</title>
|
<title>SqlSugar 5.0+ .Net Framework 4.5+ , SqlSugar 4.0+ .Net Framework 4.0+</title>
|
||||||
<authors>sun kaixuan</authors>
|
<authors>sun kaixuan</authors>
|
||||||
<owners>landa</owners>
|
<owners>landa</owners>
|
||||||
|
@@ -777,45 +777,39 @@ namespace SqlSugar
|
|||||||
result = GetData<T>(typeof(T), dataReader);
|
result = GetData<T>(typeof(T), dataReader);
|
||||||
}
|
}
|
||||||
List<T2> result2 = null;
|
List<T2> result2 = null;
|
||||||
if (DbReader.HasRows)
|
if (NextResult(dataReader))
|
||||||
{
|
{
|
||||||
this.Context.InitMappingInfo<T2>();
|
this.Context.InitMappingInfo<T2>();
|
||||||
NextResult(dataReader);
|
|
||||||
result2 = GetData<T2>(typeof(T2), dataReader);
|
result2 = GetData<T2>(typeof(T2), dataReader);
|
||||||
}
|
}
|
||||||
List<T3> result3 = null;
|
List<T3> result3 = null;
|
||||||
if (DbReader.HasRows)
|
if (NextResult(dataReader))
|
||||||
{
|
{
|
||||||
this.Context.InitMappingInfo<T3>();
|
this.Context.InitMappingInfo<T3>();
|
||||||
NextResult(dataReader);
|
|
||||||
result3 = GetData<T3>(typeof(T3), dataReader);
|
result3 = GetData<T3>(typeof(T3), dataReader);
|
||||||
}
|
}
|
||||||
List<T4> result4 = null;
|
List<T4> result4 = null;
|
||||||
if (DbReader.HasRows)
|
if (NextResult(dataReader))
|
||||||
{
|
{
|
||||||
this.Context.InitMappingInfo<T4>();
|
this.Context.InitMappingInfo<T4>();
|
||||||
NextResult(dataReader);
|
|
||||||
result4 = GetData<T4>(typeof(T4), dataReader);
|
result4 = GetData<T4>(typeof(T4), dataReader);
|
||||||
}
|
}
|
||||||
List<T5> result5 = null;
|
List<T5> result5 = null;
|
||||||
if (DbReader.HasRows)
|
if (NextResult(dataReader))
|
||||||
{
|
{
|
||||||
this.Context.InitMappingInfo<T5>();
|
this.Context.InitMappingInfo<T5>();
|
||||||
NextResult(dataReader);
|
|
||||||
result5 = GetData<T5>(typeof(T5), dataReader);
|
result5 = GetData<T5>(typeof(T5), dataReader);
|
||||||
}
|
}
|
||||||
List<T6> result6 = null;
|
List<T6> result6 = null;
|
||||||
if (DbReader.HasRows)
|
if (NextResult(dataReader))
|
||||||
{
|
{
|
||||||
this.Context.InitMappingInfo<T6>();
|
this.Context.InitMappingInfo<T6>();
|
||||||
NextResult(dataReader);
|
|
||||||
result6 = GetData<T6>(typeof(T6), dataReader);
|
result6 = GetData<T6>(typeof(T6), dataReader);
|
||||||
}
|
}
|
||||||
List<T7> result7 = null;
|
List<T7> result7 = null;
|
||||||
if (DbReader.HasRows)
|
if (NextResult(dataReader))
|
||||||
{
|
{
|
||||||
this.Context.InitMappingInfo<T7>();
|
this.Context.InitMappingInfo<T7>();
|
||||||
NextResult(dataReader);
|
|
||||||
result7 = GetData<T7>(typeof(T7), dataReader);
|
result7 = GetData<T7>(typeof(T7), dataReader);
|
||||||
}
|
}
|
||||||
builder.SqlQueryBuilder.Clear();
|
builder.SqlQueryBuilder.Clear();
|
||||||
@@ -834,7 +828,6 @@ namespace SqlSugar
|
|||||||
return Tuple.Create<List<T>, List<T2>, List<T3>, List<T4>, List<T5>, List<T6>, List<T7>>(result, result2, result3, result4, result5, result6, result7);
|
return Tuple.Create<List<T>, List<T2>, List<T3>, List<T4>, List<T5>, List<T6>, List<T7>>(result, result2, result3, result4, result5, result6, result7);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual Task<List<T>> SqlQueryAsync<T>(string sql, object parameters = null)
|
public virtual Task<List<T>> SqlQueryAsync<T>(string sql, object parameters = null)
|
||||||
{
|
{
|
||||||
var sugarParameters = this.GetParameters(parameters);
|
var sugarParameters = this.GetParameters(parameters);
|
||||||
@@ -898,45 +891,39 @@ namespace SqlSugar
|
|||||||
result =await GetDataAsync<T>(typeof(T), dataReader);
|
result =await GetDataAsync<T>(typeof(T), dataReader);
|
||||||
}
|
}
|
||||||
List<T2> result2 = null;
|
List<T2> result2 = null;
|
||||||
if (DbReader.HasRows)
|
if (NextResult(dataReader))
|
||||||
{
|
{
|
||||||
this.Context.InitMappingInfo<T2>();
|
this.Context.InitMappingInfo<T2>();
|
||||||
NextResult(dataReader);
|
|
||||||
result2 = await GetDataAsync<T2>(typeof(T2), dataReader);
|
result2 = await GetDataAsync<T2>(typeof(T2), dataReader);
|
||||||
}
|
}
|
||||||
List<T3> result3 = null;
|
List<T3> result3 = null;
|
||||||
if (DbReader.HasRows)
|
if (NextResult(dataReader))
|
||||||
{
|
{
|
||||||
this.Context.InitMappingInfo<T3>();
|
this.Context.InitMappingInfo<T3>();
|
||||||
NextResult(dataReader);
|
|
||||||
result3 = await GetDataAsync<T3>(typeof(T3), dataReader);
|
result3 = await GetDataAsync<T3>(typeof(T3), dataReader);
|
||||||
}
|
}
|
||||||
List<T4> result4 = null;
|
List<T4> result4 = null;
|
||||||
if (DbReader.HasRows)
|
if (NextResult(dataReader))
|
||||||
{
|
{
|
||||||
this.Context.InitMappingInfo<T4>();
|
this.Context.InitMappingInfo<T4>();
|
||||||
NextResult(dataReader);
|
|
||||||
result4 = await GetDataAsync<T4>(typeof(T4), dataReader);
|
result4 = await GetDataAsync<T4>(typeof(T4), dataReader);
|
||||||
}
|
}
|
||||||
List<T5> result5 = null;
|
List<T5> result5 = null;
|
||||||
if (DbReader.HasRows)
|
if (NextResult(dataReader))
|
||||||
{
|
{
|
||||||
this.Context.InitMappingInfo<T5>();
|
this.Context.InitMappingInfo<T5>();
|
||||||
NextResult(dataReader);
|
|
||||||
result5 = await GetDataAsync<T5>(typeof(T5), dataReader);
|
result5 = await GetDataAsync<T5>(typeof(T5), dataReader);
|
||||||
}
|
}
|
||||||
List<T6> result6 = null;
|
List<T6> result6 = null;
|
||||||
if (DbReader.HasRows)
|
if (NextResult(dataReader))
|
||||||
{
|
{
|
||||||
this.Context.InitMappingInfo<T6>();
|
this.Context.InitMappingInfo<T6>();
|
||||||
NextResult(dataReader);
|
|
||||||
result6 = await GetDataAsync<T6>(typeof(T6), dataReader);
|
result6 = await GetDataAsync<T6>(typeof(T6), dataReader);
|
||||||
}
|
}
|
||||||
List<T7> result7 = null;
|
List<T7> result7 = null;
|
||||||
if (DbReader.HasRows)
|
if (NextResult(dataReader))
|
||||||
{
|
{
|
||||||
this.Context.InitMappingInfo<T7>();
|
this.Context.InitMappingInfo<T7>();
|
||||||
NextResult(dataReader);
|
|
||||||
result7 = await GetDataAsync<T7>(typeof(T7), dataReader);
|
result7 = await GetDataAsync<T7>(typeof(T7), dataReader);
|
||||||
}
|
}
|
||||||
builder.SqlQueryBuilder.Clear();
|
builder.SqlQueryBuilder.Clear();
|
||||||
@@ -1165,17 +1152,29 @@ namespace SqlSugar
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Helper
|
#region Helper
|
||||||
private static void NextResult(IDataReader dataReader)
|
//private static void NextResult(IDataReader dataReader)
|
||||||
|
//{
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// NextResult(dataReader);
|
||||||
|
// }
|
||||||
|
// catch
|
||||||
|
// {
|
||||||
|
// // Check.Exception(true, ErrorMessage.GetThrowMessage("Please reduce the number of T. Save Queue Changes queries don't have so many results", "请减少T的数量,SaveQueueChanges 查询没有这么多结果"));
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
private static bool NextResult(IDataReader dataReader)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dataReader.NextResult();
|
return dataReader.NextResult();
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
// Check.Exception(true, ErrorMessage.GetThrowMessage("Please reduce the number of T. Save Queue Changes queries don't have so many results", "请减少T的数量,SaveQueueChanges 查询没有这么多结果"));
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExecuteProcessingSQL(ref string sql, SugarParameter[] parameters)
|
private void ExecuteProcessingSQL(ref string sql, SugarParameter[] parameters)
|
||||||
{
|
{
|
||||||
var result = this.ProcessingEventStartingSQL(sql, parameters);
|
var result = this.ProcessingEventStartingSQL(sql, parameters);
|
||||||
|
@@ -73,6 +73,9 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
var queryable = this.Context.Queryable<T>().WithCacheIF(IsCache, CacheTime);
|
var queryable = this.Context.Queryable<T>().WithCacheIF(IsCache, CacheTime);
|
||||||
CopyQueryBuilder(queryable.QueryBuilder);
|
CopyQueryBuilder(queryable.QueryBuilder);
|
||||||
|
((QueryableProvider<T>)queryable).MapperAction = this.MapperAction;
|
||||||
|
((QueryableProvider<T>)queryable).MapperActionWithCache = this.MapperActionWithCache;
|
||||||
|
((QueryableProvider<T>)queryable).Mappers = this.Mappers;
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
public virtual ISugarQueryable<T> AS<T2>(string tableName)
|
public virtual ISugarQueryable<T> AS<T2>(string tableName)
|
||||||
|
@@ -31,6 +31,7 @@ namespace SqlSugar
|
|||||||
public bool IsNoUpdateDefaultValue { get; set; }
|
public bool IsNoUpdateDefaultValue { get; set; }
|
||||||
public List<string> PrimaryKeys { get; set; }
|
public List<string> PrimaryKeys { get; set; }
|
||||||
public bool IsOffIdentity { get; set; }
|
public bool IsOffIdentity { get; set; }
|
||||||
|
public bool IsWhereColumns { get; set; }
|
||||||
|
|
||||||
public virtual string SqlTemplate
|
public virtual string SqlTemplate
|
||||||
{
|
{
|
||||||
@@ -253,6 +254,15 @@ namespace SqlSugar
|
|||||||
whereString += Builder.GetTranslationColumnName(item) + "=" + this.Context.Ado.SqlParameterKeyWord + item;
|
whereString += Builder.GetTranslationColumnName(item) + "=" + this.Context.Ado.SqlParameterKeyWord + item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (PrimaryKeys.HasValue()&&IsWhereColumns)
|
||||||
|
{
|
||||||
|
foreach (var item in PrimaryKeys)
|
||||||
|
{
|
||||||
|
var isFirst = whereString == null;
|
||||||
|
whereString += (isFirst ? " WHERE " : " AND ");
|
||||||
|
whereString += Builder.GetTranslationColumnName(item) + "=" + this.Context.Ado.SqlParameterKeyWord + item;
|
||||||
|
}
|
||||||
|
}
|
||||||
return string.Format(SqlTemplate, GetTableNameString, columnsString, whereString);
|
return string.Format(SqlTemplate, GetTableNameString, columnsString, whereString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -167,6 +167,7 @@ namespace SqlSugar
|
|||||||
public IUpdateable<T> WhereColumns(Expression<Func<T, object>> columns)
|
public IUpdateable<T> WhereColumns(Expression<Func<T, object>> columns)
|
||||||
{
|
{
|
||||||
this.IsWhereColumns = true;
|
this.IsWhereColumns = true;
|
||||||
|
UpdateBuilder.IsWhereColumns = true;
|
||||||
Check.Exception(UpdateParameterIsNull == true, "Updateable<T>().Updateable is error,Use Updateable(obj).WhereColumns");
|
Check.Exception(UpdateParameterIsNull == true, "Updateable<T>().Updateable is error,Use Updateable(obj).WhereColumns");
|
||||||
var whereColumns = UpdateBuilder.GetExpressionValue(columns, ResolveExpressType.ArraySingle).GetResultArray().Select(it => this.SqlBuilder.GetNoTranslationColumnName(it)).ToList();
|
var whereColumns = UpdateBuilder.GetExpressionValue(columns, ResolveExpressType.ArraySingle).GetResultArray().Select(it => this.SqlBuilder.GetNoTranslationColumnName(it)).ToList();
|
||||||
if (this.WhereColumnList == null) this.WhereColumnList = new List<string>();
|
if (this.WhereColumnList == null) this.WhereColumnList = new List<string>();
|
||||||
|
@@ -9,7 +9,8 @@ namespace SqlSugar
|
|||||||
public class MethodCallExpressionModel
|
public class MethodCallExpressionModel
|
||||||
{
|
{
|
||||||
public List<MethodCallExpressionArgs> Args { get; set; }
|
public List<MethodCallExpressionArgs> Args { get; set; }
|
||||||
public string Name { get; internal set; }
|
public string Name { get; set; }
|
||||||
|
public dynamic Data { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MethodCallExpressionArgs
|
public class MethodCallExpressionArgs
|
||||||
|
@@ -93,6 +93,44 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual string ContainsArrayUseSqlParameters(MethodCallExpressionModel model)
|
||||||
|
{
|
||||||
|
var inValueIEnumerable = (IEnumerable)model.Args[0].MemberValue;
|
||||||
|
List<object> inValues = new List<object>();
|
||||||
|
if (inValueIEnumerable != null)
|
||||||
|
{
|
||||||
|
foreach (var item in inValueIEnumerable)
|
||||||
|
{
|
||||||
|
if (item != null && item.GetType().IsEnum())
|
||||||
|
{
|
||||||
|
inValues.Add(Convert.ToInt64(item));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inValues.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var value = model.Args[1].MemberName;
|
||||||
|
string inValueString = null;
|
||||||
|
if (inValues != null && inValues.Count > 0)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < inValues.Count; i++)
|
||||||
|
{
|
||||||
|
inValueString += model.Data + "_" + i+",";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (inValueString.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
return " (1=2) ";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inValueString=inValueString.TrimEnd(',');
|
||||||
|
return string.Format(" ({0} IN ({1})) ", value, inValueString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public virtual string Equals(MethodCallExpressionModel model)
|
public virtual string Equals(MethodCallExpressionModel model)
|
||||||
{
|
{
|
||||||
var parameter = model.Args[0];
|
var parameter = model.Args[0];
|
||||||
|
@@ -20,6 +20,7 @@ namespace SqlSugar
|
|||||||
string Trim(MethodCallExpressionModel model);
|
string Trim(MethodCallExpressionModel model);
|
||||||
string Contains(MethodCallExpressionModel model);
|
string Contains(MethodCallExpressionModel model);
|
||||||
string ContainsArray(MethodCallExpressionModel model);
|
string ContainsArray(MethodCallExpressionModel model);
|
||||||
|
string ContainsArrayUseSqlParameters(MethodCallExpressionModel model);
|
||||||
string Equals(MethodCallExpressionModel model);
|
string Equals(MethodCallExpressionModel model);
|
||||||
string DateIsSameDay(MethodCallExpressionModel model);
|
string DateIsSameDay(MethodCallExpressionModel model);
|
||||||
string DateIsSameByType(MethodCallExpressionModel model);
|
string DateIsSameByType(MethodCallExpressionModel model);
|
||||||
|
@@ -37,9 +37,21 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return thisValue.Contains(parameterValue);
|
return thisValue.Contains(parameterValue);
|
||||||
}
|
}
|
||||||
public static bool ContainsArray<T>(T[] thisValue, object parameterValue)
|
public static bool ContainsArray<T>(T[] thisValue, object InField)
|
||||||
{
|
{
|
||||||
return thisValue.Contains((T)parameterValue);
|
return thisValue.Contains((T)InField);
|
||||||
|
}
|
||||||
|
public static bool ContainsArray<T>(List<T> thisValue, object InField)
|
||||||
|
{
|
||||||
|
return thisValue.Contains((T)InField);
|
||||||
|
}
|
||||||
|
public static bool ContainsArrayUseSqlParameters<T>(List<T> thisValue, object InField)
|
||||||
|
{
|
||||||
|
return thisValue.Contains((T)InField);
|
||||||
|
}
|
||||||
|
public static bool ContainsArrayUseSqlParameters<T>(T[] thisValue, object InField)
|
||||||
|
{
|
||||||
|
return thisValue.Contains((T)InField);
|
||||||
}
|
}
|
||||||
public static bool StartsWith(string thisValue, string parameterValue)
|
public static bool StartsWith(string thisValue, string parameterValue)
|
||||||
{
|
{
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -539,6 +540,30 @@ namespace SqlSugar
|
|||||||
var caResult = this.Context.DbMehtods.ContainsArray(model);
|
var caResult = this.Context.DbMehtods.ContainsArray(model);
|
||||||
this.Context.Parameters.RemoveAll(it => it.ParameterName == model.Args[0].MemberName.ObjToString());
|
this.Context.Parameters.RemoveAll(it => it.ParameterName == model.Args[0].MemberName.ObjToString());
|
||||||
return caResult;
|
return caResult;
|
||||||
|
case "ContainsArrayUseSqlParameters":
|
||||||
|
if (model.Args[0].MemberValue == null)
|
||||||
|
{
|
||||||
|
var first = this.Context.Parameters.FirstOrDefault(it => it.ParameterName == model.Args[0].MemberName.ObjToString());
|
||||||
|
if (first.HasValue())
|
||||||
|
{
|
||||||
|
model.Args[0].MemberValue = first.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
model.Data =this.Context.SqlParameterKeyWord+"INP_"+this.Context.ParameterIndex;
|
||||||
|
this.Context.ParameterIndex++;
|
||||||
|
if (model.Args[0].MemberValue.HasValue())
|
||||||
|
{
|
||||||
|
var inValueIEnumerable = (IEnumerable)model.Args[0].MemberValue;
|
||||||
|
int i = 0;
|
||||||
|
foreach (var item in inValueIEnumerable)
|
||||||
|
{
|
||||||
|
this.Context.Parameters.Add(new SugarParameter(model.Data+"_"+i,item));
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var caResult2 = this.Context.DbMehtods.ContainsArrayUseSqlParameters(model);
|
||||||
|
this.Context.Parameters.RemoveAll(it => it.ParameterName == model.Args[0].MemberName.ObjToString());
|
||||||
|
return caResult2;
|
||||||
case "Equals":
|
case "Equals":
|
||||||
return this.Context.DbMehtods.Equals(model);
|
return this.Context.DbMehtods.Equals(model);
|
||||||
case "DateIsSame":
|
case "DateIsSame":
|
||||||
|
@@ -356,7 +356,7 @@ namespace SqlSugar
|
|||||||
|
|
||||||
public override List<DbColumnInfo> GetColumnInfosByTableName(string tableName, bool isCache = true)
|
public override List<DbColumnInfo> GetColumnInfosByTableName(string tableName, bool isCache = true)
|
||||||
{
|
{
|
||||||
return base.GetColumnInfosByTableName(tableName.ToLower(), isCache);
|
return base.GetColumnInfosByTableName(tableName.TrimEnd('"').TrimStart('"').ToLower(), isCache);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
@@ -13,7 +13,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
InsertBuilder.IsReturnIdentity = true;
|
InsertBuilder.IsReturnIdentity = true;
|
||||||
PreToSql();
|
PreToSql();
|
||||||
string sql = InsertBuilder.ToSqlString().Replace("$PrimaryKey", GetPrimaryKeys().FirstOrDefault());
|
string sql = InsertBuilder.ToSqlString().Replace("$PrimaryKey", GetIdentityKeys().FirstOrDefault());
|
||||||
RestoreMapping();
|
RestoreMapping();
|
||||||
var result = Ado.GetScalar(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray()).ObjToInt();
|
var result = Ado.GetScalar(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray()).ObjToInt();
|
||||||
return result;
|
return result;
|
||||||
@@ -22,7 +22,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
InsertBuilder.IsReturnIdentity = true;
|
InsertBuilder.IsReturnIdentity = true;
|
||||||
PreToSql();
|
PreToSql();
|
||||||
string sql = InsertBuilder.ToSqlString().Replace("$PrimaryKey", GetPrimaryKeys().FirstOrDefault());
|
string sql = InsertBuilder.ToSqlString().Replace("$PrimaryKey", GetIdentityKeys().FirstOrDefault());
|
||||||
RestoreMapping();
|
RestoreMapping();
|
||||||
var obj = await Ado.GetScalarAsync(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray());
|
var obj = await Ado.GetScalarAsync(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray());
|
||||||
var result = obj.ObjToInt();
|
var result = obj.ObjToInt();
|
||||||
@@ -38,7 +38,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
InsertBuilder.IsReturnIdentity = true;
|
InsertBuilder.IsReturnIdentity = true;
|
||||||
PreToSql();
|
PreToSql();
|
||||||
string sql = InsertBuilder.ToSqlString().Replace("$PrimaryKey", GetPrimaryKeys().FirstOrDefault());
|
string sql = InsertBuilder.ToSqlString().Replace("$PrimaryKey", GetIdentityKeys().FirstOrDefault());
|
||||||
RestoreMapping();
|
RestoreMapping();
|
||||||
var result = Convert.ToInt64(Ado.GetScalar(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray()) ?? "0");
|
var result = Convert.ToInt64(Ado.GetScalar(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray()) ?? "0");
|
||||||
return result;
|
return result;
|
||||||
@@ -47,7 +47,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
InsertBuilder.IsReturnIdentity = true;
|
InsertBuilder.IsReturnIdentity = true;
|
||||||
PreToSql();
|
PreToSql();
|
||||||
string sql = InsertBuilder.ToSqlString().Replace("$PrimaryKey", GetPrimaryKeys().FirstOrDefault());
|
string sql = InsertBuilder.ToSqlString().Replace("$PrimaryKey", GetIdentityKeys().FirstOrDefault());
|
||||||
RestoreMapping();
|
RestoreMapping();
|
||||||
var result = Convert.ToInt64(await Ado.GetScalarAsync(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray()) ?? "0");
|
var result = Convert.ToInt64(await Ado.GetScalarAsync(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray()) ?? "0");
|
||||||
return result;
|
return result;
|
||||||
|
Reference in New Issue
Block a user