mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
Update Core
This commit is contained in:
parent
b2c74daa2c
commit
3a7fcf7150
@ -26,7 +26,10 @@ namespace SqlSugar
|
||||
if (isDictionary)
|
||||
DictionaryToParameters(parameters, sqlParameterKeyWord, result, entityType);
|
||||
else
|
||||
{
|
||||
Check.Exception(!entityType.IsAnonymousType(), "The parameter format is wrong. \nUse new{{xx=xx, xx2=xx2}} or \nDictionary<string, object> or \nSugarParameter [] ");
|
||||
ProperyToParameter(parameters, propertyInfo, sqlParameterKeyWord, result, entityType);
|
||||
}
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
|
@ -51,9 +51,10 @@ namespace SqlSugar
|
||||
public virtual CommandType CommandType { get; set; }
|
||||
public virtual bool IsEnableLogEvent { get; set; }
|
||||
public virtual bool IsClearParameters { get; set; }
|
||||
public virtual Action<string, string> LogEventStarting { get; set; }
|
||||
public virtual Action<string, string> LogEventCompleted { get; set; }
|
||||
public virtual Action<string, SugarParameter[]> LogEventStarting { get; set; }
|
||||
public virtual Action<string, SugarParameter[]> LogEventCompleted { get; set; }
|
||||
public virtual Func<string, SugarParameter[], KeyValuePair<string, SugarParameter[]>> ProcessingEventStartingSQL { get; set; }
|
||||
public virtual Action<Exception> ErrorEvent { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Connection
|
||||
@ -241,6 +242,8 @@ namespace SqlSugar
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ErrorEvent != null)
|
||||
ErrorEvent(ex);
|
||||
throw ex;
|
||||
}
|
||||
finally
|
||||
@ -250,18 +253,27 @@ namespace SqlSugar
|
||||
}
|
||||
public virtual IDataReader GetDataReader(string sql, params SugarParameter[] parameters)
|
||||
{
|
||||
var isSp = this.CommandType == CommandType.StoredProcedure;
|
||||
if (this.ProcessingEventStartingSQL != null)
|
||||
ExecuteProcessingSQL(ref sql, parameters);
|
||||
ExecuteBefore(sql, parameters);
|
||||
IDbCommand sqlCommand = GetCommand(sql, parameters);
|
||||
IDataReader sqlDataReader = sqlCommand.ExecuteReader(this.IsClose() ? CommandBehavior.CloseConnection : CommandBehavior.Default);
|
||||
if (isSp)
|
||||
DataReaderParameters = sqlCommand.Parameters;
|
||||
if (this.IsClearParameters)
|
||||
sqlCommand.Parameters.Clear();
|
||||
ExecuteAfter(sql, parameters);
|
||||
return sqlDataReader;
|
||||
try
|
||||
{
|
||||
var isSp = this.CommandType == CommandType.StoredProcedure;
|
||||
if (this.ProcessingEventStartingSQL != null)
|
||||
ExecuteProcessingSQL(ref sql, parameters);
|
||||
ExecuteBefore(sql, parameters);
|
||||
IDbCommand sqlCommand = GetCommand(sql, parameters);
|
||||
IDataReader sqlDataReader = sqlCommand.ExecuteReader(this.IsClose() ? CommandBehavior.CloseConnection : CommandBehavior.Default);
|
||||
if (isSp)
|
||||
DataReaderParameters = sqlCommand.Parameters;
|
||||
if (this.IsClearParameters)
|
||||
sqlCommand.Parameters.Clear();
|
||||
ExecuteAfter(sql, parameters);
|
||||
return sqlDataReader;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ErrorEvent != null)
|
||||
ErrorEvent(ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
public virtual DataSet GetDataSetAll(string sql, params SugarParameter[] parameters)
|
||||
{
|
||||
@ -282,6 +294,8 @@ namespace SqlSugar
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ErrorEvent != null)
|
||||
ErrorEvent(ex);
|
||||
throw ex;
|
||||
}
|
||||
finally
|
||||
@ -306,6 +320,8 @@ namespace SqlSugar
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ErrorEvent != null)
|
||||
ErrorEvent(ex);
|
||||
throw ex;
|
||||
}
|
||||
finally
|
||||
@ -578,16 +594,16 @@ namespace SqlSugar
|
||||
{
|
||||
if (this.IsEnableLogEvent)
|
||||
{
|
||||
Action<string, string> action = LogEventStarting;
|
||||
Action<string, SugarParameter[]> action = LogEventStarting;
|
||||
if (action != null)
|
||||
{
|
||||
if (parameters == null || parameters.Length == 0)
|
||||
{
|
||||
action(sql, null);
|
||||
action(sql, new SugarParameter[] { });
|
||||
}
|
||||
else
|
||||
{
|
||||
action(sql, this.Context.Utilities.SerializeObject(parameters.Select(it => new { key = it.ParameterName, value = it.Value.ObjToString() })));
|
||||
action(sql, parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -606,16 +622,16 @@ namespace SqlSugar
|
||||
}
|
||||
if (this.IsEnableLogEvent)
|
||||
{
|
||||
Action<string, string> action = LogEventCompleted;
|
||||
Action<string, SugarParameter[]> action = LogEventCompleted;
|
||||
if (action != null)
|
||||
{
|
||||
if (parameters == null || parameters.Length == 0)
|
||||
{
|
||||
action(sql, null);
|
||||
action(sql, new SugarParameter[] { });
|
||||
}
|
||||
else
|
||||
{
|
||||
action(sql, this.Context.Utilities.SerializeObject(parameters.Select(it => new { key = it.ParameterName, value = it.Value.ObjToString() })));
|
||||
action(sql, parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
public class AopProvider
|
||||
{
|
||||
private AopProvider() { }
|
||||
public AopProvider(SqlSugarClient context)
|
||||
{
|
||||
this.Context = context;
|
||||
this.Context.Ado.IsEnableLogEvent = true;
|
||||
}
|
||||
private SqlSugarClient Context { get; set; }
|
||||
public Action<Exception> OnError { set { this.Context.Ado.ErrorEvent = value; } }
|
||||
public Action<string, SugarParameter[]> OnLogExecuting { set { this.Context.Ado.LogEventStarting = value; } }
|
||||
public Action<string, SugarParameter[]> OnLogExecuted { set { this.Context.Ado.LogEventCompleted = value; } }
|
||||
public Func<string, SugarParameter[], KeyValuePair<string, SugarParameter[]>> OnExecutingChangeSql { set { this.Context.Ado.ProcessingEventStartingSQL = value; } }
|
||||
}
|
||||
}
|
@ -38,6 +38,8 @@ namespace SqlSugar
|
||||
private static readonly MethodInfo getInt32 = typeof(IDataRecord).GetMethod("GetInt32", new Type[] { typeof(int) });
|
||||
private static readonly MethodInfo getInt64 = typeof(IDataRecord).GetMethod("GetInt64", new Type[] { typeof(int) });
|
||||
private static readonly MethodInfo getString = typeof(IDataRecord).GetMethod("GetString", new Type[] { typeof(int) });
|
||||
private static readonly MethodInfo getdatetimeoffset = typeof(IDataRecordExtensions).GetMethod("Getdatetimeoffset");
|
||||
private static readonly MethodInfo getdatetimeoffsetDate = typeof(IDataRecordExtensions).GetMethod("GetdatetimeoffsetDate");
|
||||
private static readonly MethodInfo getStringGuid = typeof(IDataRecordExtensions).GetMethod("GetStringGuid");
|
||||
private static readonly MethodInfo getConvertStringGuid = typeof(IDataRecordExtensions).GetMethod("GetConvertStringGuid");
|
||||
private static readonly MethodInfo getEnum = typeof(IDataRecordExtensions).GetMethod("GetEnum");
|
||||
@ -54,11 +56,14 @@ namespace SqlSugar
|
||||
private static readonly MethodInfo getConvertInt32 = typeof(IDataRecordExtensions).GetMethod("GetConvertInt32");
|
||||
private static readonly MethodInfo getConvertInt64 = typeof(IDataRecordExtensions).GetMethod("GetConvetInt64");
|
||||
private static readonly MethodInfo getConvertEnum_Null = typeof(IDataRecordExtensions).GetMethod("GetConvertEnum_Null");
|
||||
private static readonly MethodInfo getConvertdatetimeoffset = typeof(IDataRecordExtensions).GetMethod("GetConvertdatetimeoffset");
|
||||
private static readonly MethodInfo getConvertdatetimeoffsetDate = typeof(IDataRecordExtensions).GetMethod("GetConvertdatetimeoffsetDate");
|
||||
private static readonly MethodInfo getOtherNull = typeof(IDataRecordExtensions).GetMethod("GetOtherNull");
|
||||
private static readonly MethodInfo getOther = typeof(IDataRecordExtensions).GetMethod("GetOther");
|
||||
private static readonly MethodInfo getSqliteTypeNull = typeof(IDataRecordExtensions).GetMethod("GetSqliteTypeNull");
|
||||
private static readonly MethodInfo getSqliteType = typeof(IDataRecordExtensions).GetMethod("GetSqliteType");
|
||||
private static readonly MethodInfo getEntity = typeof(IDataRecordExtensions).GetMethod("GetEntity", new Type[] { typeof(SqlSugarClient) });
|
||||
|
||||
private delegate T Load(IDataRecord dataRecord);
|
||||
private Load handler;
|
||||
#endregion
|
||||
@ -278,6 +283,11 @@ namespace SqlSugar
|
||||
if (bindProperyTypeName == "int64" || bindProperyTypeName == "long")
|
||||
method = isNullableType ? getConvertInt64 : getInt64;
|
||||
break;
|
||||
case CSharpDataType.DateTimeOffset:
|
||||
method = isNullableType ? getConvertdatetimeoffset : getdatetimeoffset;
|
||||
if (bindProperyTypeName == "datetime")
|
||||
method = isNullableType ? getConvertdatetimeoffsetDate : getdatetimeoffsetDate;
|
||||
break;
|
||||
default:
|
||||
method = getValueMethod;
|
||||
break;
|
||||
|
@ -132,6 +132,49 @@ namespace SqlSugar
|
||||
return reval;
|
||||
}
|
||||
|
||||
public static DateTime GetdatetimeoffsetDate(this IDataRecord dr, int i)
|
||||
{
|
||||
if (dr.IsDBNull(i))
|
||||
{
|
||||
return DateTime.MinValue;
|
||||
}
|
||||
var offsetValue = (DateTimeOffset)dr.GetValue(i);
|
||||
var reval = offsetValue.DateTime;
|
||||
return reval;
|
||||
}
|
||||
|
||||
public static DateTime? GetConvertdatetimeoffsetDate(this IDataRecord dr, int i)
|
||||
{
|
||||
if (dr.IsDBNull(i))
|
||||
{
|
||||
return DateTime.MinValue;
|
||||
}
|
||||
var offsetValue = (DateTimeOffset)dr.GetValue(i);
|
||||
var reval = offsetValue.DateTime;
|
||||
return reval;
|
||||
}
|
||||
|
||||
public static DateTimeOffset Getdatetimeoffset(this IDataRecord dr, int i)
|
||||
{
|
||||
if (dr.IsDBNull(i))
|
||||
{
|
||||
return default(DateTimeOffset);
|
||||
}
|
||||
var reval = (DateTimeOffset)dr.GetValue(i);
|
||||
return reval;
|
||||
}
|
||||
|
||||
public static DateTimeOffset? GetConvertdatetimeoffset(this IDataRecord dr, int i)
|
||||
{
|
||||
if (dr.IsDBNull(i))
|
||||
{
|
||||
return default(DateTimeOffset);
|
||||
}
|
||||
var reval = (DateTimeOffset)dr.GetValue(i);
|
||||
return reval;
|
||||
}
|
||||
|
||||
|
||||
public static string GetConvertString(this IDataRecord dr, int i)
|
||||
{
|
||||
if (dr.IsDBNull(i))
|
||||
|
@ -177,7 +177,7 @@ namespace SqlSugar
|
||||
PropertyDescriptionText = GetPropertyDescriptionText(item, PropertyDescriptionText);
|
||||
PropertyText = PropertyDescriptionText + PropertyText;
|
||||
classText = classText.Replace(DbFirstTemplate.KeyPropertyName, PropertyText + (isLast ? "" : ("\r\n" + DbFirstTemplate.KeyPropertyName)));
|
||||
if (ConstructorText.IsValuable() && item.DefaultValue.IsValuable())
|
||||
if (ConstructorText.IsValuable() && item.DefaultValue!=null)
|
||||
{
|
||||
var hasDefaultValue = columns.Skip(index + 1).Any(it=>it.DefaultValue.IsValuable());
|
||||
ConstructorText = ConstructorText.Replace(DbFirstTemplate.KeyPropertyName, propertyName);
|
||||
|
@ -1255,7 +1255,7 @@ namespace SqlSugar
|
||||
});
|
||||
return this;
|
||||
}
|
||||
public new ISugarQueryable<T, T2> With(string withString)
|
||||
public new ISugarQueryable<T,T2> With(string withString)
|
||||
{
|
||||
base.With(withString);
|
||||
return this;
|
||||
@ -1415,7 +1415,7 @@ namespace SqlSugar
|
||||
#endregion
|
||||
|
||||
#region Other
|
||||
public new ISugarQueryable<T, T2, T3> AS<AsT>(string tableName)
|
||||
public new ISugarQueryable<T, T2,T3> AS<AsT>(string tableName)
|
||||
{
|
||||
var entityName = typeof(AsT).Name;
|
||||
_As(tableName, entityName);
|
||||
@ -1645,7 +1645,7 @@ namespace SqlSugar
|
||||
#endregion
|
||||
|
||||
#region Other
|
||||
public new ISugarQueryable<T, T2, T3, T4> AS<AsT>(string tableName)
|
||||
public new ISugarQueryable<T, T2, T3,T4> AS<AsT>(string tableName)
|
||||
{
|
||||
var entityName = typeof(AsT).Name;
|
||||
_As(tableName, entityName);
|
||||
@ -1901,7 +1901,7 @@ namespace SqlSugar
|
||||
#endregion
|
||||
|
||||
#region Other
|
||||
public new ISugarQueryable<T, T2, T3, T4, T5> AS<AsT>(string tableName)
|
||||
public new ISugarQueryable<T, T2, T3, T4,T5> AS<AsT>(string tableName)
|
||||
{
|
||||
var entityName = typeof(AsT).Name;
|
||||
_As(tableName, entityName);
|
||||
@ -2183,7 +2183,7 @@ namespace SqlSugar
|
||||
#endregion
|
||||
|
||||
#region Other
|
||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6> AS<AsT>(string tableName)
|
||||
public new ISugarQueryable<T, T2, T3, T4, T5,T6> AS<AsT>(string tableName)
|
||||
{
|
||||
var entityName = typeof(AsT).Name;
|
||||
_As(tableName, entityName);
|
||||
@ -2492,7 +2492,7 @@ namespace SqlSugar
|
||||
#endregion
|
||||
|
||||
#region Other
|
||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> AS<AsT>(string tableName)
|
||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6,T7> AS<AsT>(string tableName)
|
||||
{
|
||||
var entityName = typeof(AsT).Name;
|
||||
_As(tableName, entityName);
|
||||
@ -2827,7 +2827,7 @@ namespace SqlSugar
|
||||
#endregion
|
||||
|
||||
#region Other
|
||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> AS<AsT>(string tableName)
|
||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7,T8> AS<AsT>(string tableName)
|
||||
{
|
||||
var entityName = typeof(AsT).Name;
|
||||
_As(tableName, entityName);
|
||||
@ -3185,7 +3185,7 @@ namespace SqlSugar
|
||||
#endregion
|
||||
|
||||
#region Other
|
||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> AS<AsT>(string tableName)
|
||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> AS<AsT>(string tableName)
|
||||
{
|
||||
var entityName = typeof(AsT).Name;
|
||||
_As(tableName, entityName);
|
||||
@ -3234,7 +3234,7 @@ namespace SqlSugar
|
||||
});
|
||||
return this;
|
||||
}
|
||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> With(string withString)
|
||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> With(string withString)
|
||||
{
|
||||
base.With(withString);
|
||||
return this;
|
||||
@ -3567,7 +3567,7 @@ namespace SqlSugar
|
||||
#endregion
|
||||
|
||||
#region Other
|
||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> AS<AsT>(string tableName)
|
||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> AS<AsT>(string tableName)
|
||||
{
|
||||
var entityName = typeof(AsT).Name;
|
||||
_As(tableName, entityName);
|
||||
@ -3974,7 +3974,7 @@ namespace SqlSugar
|
||||
#endregion
|
||||
|
||||
#region Other
|
||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> AS<AsT>(string tableName)
|
||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11> AS<AsT>(string tableName)
|
||||
{
|
||||
var entityName = typeof(AsT).Name;
|
||||
_As(tableName, entityName);
|
||||
@ -4406,7 +4406,7 @@ namespace SqlSugar
|
||||
#endregion
|
||||
|
||||
#region Other
|
||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> AS<AsT>(string tableName)
|
||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> AS<AsT>(string tableName)
|
||||
{
|
||||
var entityName = typeof(AsT).Name;
|
||||
_As(tableName, entityName);
|
||||
|
@ -73,11 +73,19 @@ namespace SqlSugar
|
||||
}
|
||||
public virtual string GetPackTable(string sql, string shortName)
|
||||
{
|
||||
return UtilMethods.GetPackTable(sql,shortName);
|
||||
return UtilMethods.GetPackTable(sql, shortName);
|
||||
}
|
||||
public virtual string GetDefaultShortName()
|
||||
{
|
||||
return "t";
|
||||
}
|
||||
public virtual string GetUnionAllSql(List<string> sqlList)
|
||||
{
|
||||
return string.Join("UNION ALL \r\n", sqlList);
|
||||
}
|
||||
public virtual void RepairReplicationParameters(ref string appendSql, SugarParameter[] parameters, int addIndex)
|
||||
{
|
||||
UtilMethods.RepairReplicationParameters(ref appendSql,parameters,addIndex);
|
||||
UtilMethods.RepairReplicationParameters(ref appendSql, parameters, addIndex);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -22,6 +22,7 @@ namespace SqlSugar
|
||||
@other,
|
||||
@byteArray,
|
||||
@float,
|
||||
@time
|
||||
@time,
|
||||
@DateTimeOffset
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ namespace SqlSugar
|
||||
var isBool = expression.Type == UtilConstants.BoolType;
|
||||
var isValueBool = isValue && isBool && parameter.BaseExpression == null;
|
||||
var isLength = memberName == "Length" && childIsMember && childExpression.Type == UtilConstants.StringType;
|
||||
var isDateValue = memberName.IsIn(Enum.GetNames(typeof(DateType))) && (expression.Expression as MemberExpression).Type == UtilConstants.DateType;
|
||||
var isDateValue = memberName.IsIn(Enum.GetNames(typeof(DateType))) &&(childIsMember&&childExpression.Type == UtilConstants.DateType);
|
||||
var isLogicOperator = ExpressionTool.IsLogicOperator(baseParameter.OperatorValue) || baseParameter.OperatorValue.IsNullOrEmpty();
|
||||
var isHasValue = isLogicOperator && memberName == "HasValue" && expression.Expression != null && expression.NodeType == ExpressionType.MemberAccess;
|
||||
var isDateDate = memberName == "Date" && expression.Expression.Type == UtilConstants.DateType;
|
||||
|
@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
public class SubOrderBy : ISubOperation
|
||||
{
|
||||
public string Name
|
||||
{
|
||||
get { return "OrderBy"; }
|
||||
}
|
||||
|
||||
public Expression Expression
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public int Sort
|
||||
{
|
||||
get
|
||||
{
|
||||
return 480;
|
||||
}
|
||||
}
|
||||
|
||||
public ExpressionContext Context
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public string GetValue(Expression expression)
|
||||
{
|
||||
var exp = expression as MethodCallExpression;
|
||||
var argExp = exp.Arguments[0];
|
||||
var result = "ORDER BY " + SubTools.GetMethodValue(this.Context, argExp, ResolveExpressType.FieldSingle);
|
||||
var selfParameterName = this.Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot;
|
||||
result = result.Replace(selfParameterName, string.Empty);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
public class SubOrderByDesc : ISubOperation
|
||||
{
|
||||
public string Name
|
||||
{
|
||||
get { return "OrderByDesc"; }
|
||||
}
|
||||
|
||||
public Expression Expression
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public int Sort
|
||||
{
|
||||
get
|
||||
{
|
||||
return 480;
|
||||
}
|
||||
}
|
||||
|
||||
public ExpressionContext Context
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public string GetValue(Expression expression)
|
||||
{
|
||||
var exp = expression as MethodCallExpression;
|
||||
var argExp = exp.Arguments[0];
|
||||
var result = "ORDER BY " + SubTools.GetMethodValue(this.Context, argExp, ResolveExpressType.FieldSingle)+" DESC";
|
||||
var selfParameterName = this.Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot;
|
||||
result = result.Replace(selfParameterName, string.Empty);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
@ -35,7 +35,7 @@ namespace SqlSugar
|
||||
{
|
||||
var exp = expression as MethodCallExpression;
|
||||
var argExp= exp.Arguments[0];
|
||||
var result= "WHERE "+SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple);
|
||||
var result= "WHERE "+SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple);;
|
||||
var selfParameterName = Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name)+UtilConstants.Dot;
|
||||
result = result.Replace(selfParameterName,string.Empty);
|
||||
return result;
|
||||
|
@ -11,7 +11,7 @@ namespace SqlSugar
|
||||
public static List<ISubOperation> SubItems(ExpressionContext Context)
|
||||
{
|
||||
|
||||
return new List<ISubOperation>()
|
||||
return new List<ISubOperation>()
|
||||
{
|
||||
new SubSelect() { Context=Context },
|
||||
new SubWhere(){ Context=Context },
|
||||
@ -22,7 +22,9 @@ namespace SqlSugar
|
||||
new SubFromTable(){ Context=Context },
|
||||
new SubCount(){ Context=Context },
|
||||
new SubMax(){ Context=Context },
|
||||
new SubMin(){ Context=Context }
|
||||
new SubMin(){ Context=Context },
|
||||
new SubOrderBy(){ Context=Context },
|
||||
new SubOrderByDesc(){ Context=Context }
|
||||
};
|
||||
}
|
||||
|
||||
@ -37,6 +39,8 @@ namespace SqlSugar
|
||||
newContext.Resolve(item, type);
|
||||
context.Index = newContext.Index;
|
||||
context.ParameterIndex = newContext.ParameterIndex;
|
||||
if (newContext.Parameters.IsValuable())
|
||||
context.Parameters.AddRange(newContext.Parameters);
|
||||
return newContext.Result.GetResultString();
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,14 @@ namespace SqlSugar
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
public Subqueryable<T> OrderBy(Func<T, object> expression)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
public Subqueryable<T> OrderByDesc(Func<T, object> expression)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
public TResult Select<TResult>(Func<T, TResult> expression) where TResult :struct
|
||||
{
|
||||
return default(TResult);
|
||||
|
@ -23,9 +23,10 @@ namespace SqlSugar
|
||||
IDataParameterCollection DataReaderParameters { get; set; }
|
||||
CommandType CommandType { get; set; }
|
||||
bool IsEnableLogEvent { get; set; }
|
||||
Action<string, string> LogEventStarting { get; set; }
|
||||
Action<string, string> LogEventCompleted { get; set; }
|
||||
Action<string, SugarParameter []> LogEventStarting { get; set; }
|
||||
Action<string, SugarParameter []> LogEventCompleted { get; set; }
|
||||
Func<string, SugarParameter[], KeyValuePair<string, SugarParameter[]>> ProcessingEventStartingSQL { get; set; }
|
||||
Action<Exception> ErrorEvent { get; set; }
|
||||
bool IsClearParameters { get; set; }
|
||||
int CommandTimeOut { get; set; }
|
||||
IDbBind DbBind { get; }
|
||||
|
@ -27,6 +27,8 @@ namespace SqlSugar
|
||||
string GetTranslationColumnName(string propertyName);
|
||||
string GetNoTranslationColumnName(string name);
|
||||
string GetPackTable(string sql,string shortName);
|
||||
string GetDefaultShortName();
|
||||
string GetUnionAllSql(List<string> sqlList);
|
||||
void RepairReplicationParameters(ref string appendSql, SugarParameter[] parameters, int addIndex);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace SqlSugar
|
||||
}
|
||||
if (this.IsEnableLogEvent)
|
||||
{
|
||||
Action<string, string> action = LogEventStarting;
|
||||
Action<string, SugarParameter[]> action = LogEventStarting;
|
||||
if (action != null)
|
||||
{
|
||||
if (parameters == null || parameters.Length == 0)
|
||||
@ -34,7 +34,7 @@ namespace SqlSugar
|
||||
}
|
||||
else
|
||||
{
|
||||
action(sql, this.Context.RewritableMethods.SerializeObject(parameters.Select(it => new { key = it.ParameterName, value = it.Value.ObjToString() })));
|
||||
action(sql,parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,9 @@ namespace SqlSugar
|
||||
new KeyValuePair<string, CSharpDataType>("uniqueidentifier",CSharpDataType.Guid),
|
||||
new KeyValuePair<string, CSharpDataType>("binary",CSharpDataType.byteArray),
|
||||
new KeyValuePair<string, CSharpDataType>("image",CSharpDataType.byteArray),
|
||||
new KeyValuePair<string, CSharpDataType>("varbinary",CSharpDataType.byteArray)};
|
||||
new KeyValuePair<string, CSharpDataType>("varbinary",CSharpDataType.byteArray),
|
||||
new KeyValuePair<string, CSharpDataType>("datetimeoffset", CSharpDataType.DateTimeOffset),
|
||||
new KeyValuePair<string, CSharpDataType>("datetimeoffset", CSharpDataType.DateTime)};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +62,10 @@ namespace SqlSugar
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Aop Log Methods
|
||||
public virtual AopProvider Aop { get { return new AopProvider(this.Context); } }
|
||||
#endregion
|
||||
|
||||
#region Util Methods
|
||||
[Obsolete("Use SqlSugarClient.Utilities")]
|
||||
public virtual IRewritableMethods RewritableMethods
|
||||
@ -306,6 +310,7 @@ namespace SqlSugar
|
||||
|
||||
public virtual ISugarQueryable<T> UnionAll<T>(params ISugarQueryable<T>[] queryables) where T : class, new()
|
||||
{
|
||||
var sqlBuilder = InstanceFactory.GetSqlbuilder(this.Context.CurrentConnectionConfig);
|
||||
Check.Exception(queryables.IsNullOrEmpty(), "UnionAll.queryables is null ");
|
||||
int i = 1;
|
||||
List<KeyValuePair<string, List<SugarParameter>>> allItems = new List<KeyValuePair<string, List<SugarParameter>>>();
|
||||
@ -320,7 +325,7 @@ namespace SqlSugar
|
||||
allItems.Add(new KeyValuePair<string, List<SugarParameter>>(sql, new List<SugarParameter>()));
|
||||
i++;
|
||||
}
|
||||
var allSql = string.Join("UNION ALL \r\n", allItems.Select(it => it.Key));
|
||||
var allSql = sqlBuilder.GetUnionAllSql(allItems.Select(it => it.Key).ToList());
|
||||
var allParameters = allItems.SelectMany(it => it.Value).ToArray();
|
||||
var resulut = this.Queryable<ExpandoObject>().AS(UtilMethods.GetPackTable(allSql, "unionTable"));
|
||||
resulut.AddParameters(allParameters);
|
||||
@ -333,6 +338,14 @@ namespace SqlSugar
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SqlQueryable
|
||||
public ISugarQueryable<T> SqlQueryable<T>(string sql) where T : class, new()
|
||||
{
|
||||
var sqlBuilder = InstanceFactory.GetSqlbuilder(this.Context.CurrentConnectionConfig);
|
||||
return this.Queryable<T>().AS(sqlBuilder.GetPackTable(sql, sqlBuilder.GetDefaultShortName()));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Insertable
|
||||
public virtual IInsertable<T> Insertable<T>(T[] insertObjs) where T : class, new()
|
||||
{
|
||||
@ -483,7 +496,7 @@ namespace SqlSugar
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region DbMaintenance
|
||||
#region Db Maintenance
|
||||
public virtual IDbMaintenance DbMaintenance
|
||||
{
|
||||
get
|
||||
@ -499,7 +512,7 @@ namespace SqlSugar
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Entity Methods
|
||||
#region Entity Maintenance
|
||||
[Obsolete("Use SqlSugarClient.EntityMaintenance")]
|
||||
public virtual EntityMaintenance EntityProvider
|
||||
{
|
||||
|
@ -8,10 +8,8 @@ using System.Text;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
/// <summary>
|
||||
/// In order to be compatible with .NET CORE, make sure that the two versions are consistent in syntax
|
||||
/// </summary>
|
||||
public static class CompatibleExtensions
|
||||
|
||||
public static class ReflectionExtensions
|
||||
{
|
||||
public static Type GetTypeInfo(this Type typeInfo)
|
||||
{
|
||||
|
@ -5,7 +5,7 @@ using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
namespace SqlSugar
|
||||
{
|
||||
internal static class IsWhatExtensions
|
||||
internal static class ValidateExtensions
|
||||
{
|
||||
public static bool IsInRange(this int thisValue, int begin, int end)
|
||||
{
|
Loading…
Reference in New Issue
Block a user