mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
Update Core
This commit is contained in:
parent
3189bd1bea
commit
5c4ec2e54a
Binary file not shown.
@ -52,7 +52,7 @@ namespace SqlSugar
|
||||
private static readonly MethodInfo getConvertGuid = typeof(IDataRecordExtensions).GetMethod("GetConvertGuid");
|
||||
private static readonly MethodInfo getConvertInt16 = typeof(IDataRecordExtensions).GetMethod("GetConvertInt16");
|
||||
private static readonly MethodInfo getConvertInt32 = typeof(IDataRecordExtensions).GetMethod("GetConvertInt32");
|
||||
private static readonly MethodInfo getConvetInt64 = typeof(IDataRecordExtensions).GetMethod("GetConvetInt64");
|
||||
private static readonly MethodInfo getConvertInt64 = typeof(IDataRecordExtensions).GetMethod("GetConvetInt64");
|
||||
private static readonly MethodInfo getConvertEnum_Null = typeof(IDataRecordExtensions).GetMethod("GetConvertEnum_Null");
|
||||
private static readonly MethodInfo getOtherNull = typeof(IDataRecordExtensions).GetMethod("GetOtherNull");
|
||||
private static readonly MethodInfo getOther = typeof(IDataRecordExtensions).GetMethod("GetOther");
|
||||
@ -218,8 +218,10 @@ namespace SqlSugar
|
||||
{
|
||||
case CSharpDataType.@int:
|
||||
CheckType(bind.IntThrow, bindProperyTypeName, validPropertyName, propertyName);
|
||||
if (bindProperyTypeName.IsContainsIn("int", "int32", "int64"))
|
||||
if (bindProperyTypeName.IsContainsIn("int", "int32"))
|
||||
method = isNullableType ? getConvertInt32 : getInt32;
|
||||
if (bindProperyTypeName.IsContainsIn("int64"))
|
||||
method = isNullableType ? getConvertInt64 : getInt64;
|
||||
break;
|
||||
case CSharpDataType.@bool:
|
||||
if (bindProperyTypeName == "bool" || bindProperyTypeName == "boolean")
|
||||
@ -267,7 +269,7 @@ namespace SqlSugar
|
||||
break;
|
||||
case CSharpDataType.@long:
|
||||
if (bindProperyTypeName == "int64" || bindProperyTypeName == "long")
|
||||
method = isNullableType ? getConvetInt64 : getInt64;
|
||||
method = isNullableType ? getConvertInt64 : getInt64;
|
||||
break;
|
||||
default:
|
||||
method = getValueMethod;
|
||||
|
@ -227,6 +227,7 @@ namespace SqlSugar
|
||||
result = "DateTime.Now";
|
||||
}
|
||||
result = result.Replace("\r", "\t").Replace("\n", "\t");
|
||||
result = result.IsIn("''","\"\"") ? string.Empty : result;
|
||||
return result;
|
||||
}
|
||||
private string GetPropertyText(DbColumnInfo item, string PropertyText)
|
||||
|
@ -117,7 +117,8 @@ namespace SqlSugar
|
||||
}
|
||||
public virtual ISugarQueryable<T> Where(string whereString, object whereObj = null)
|
||||
{
|
||||
this.Where<T>(whereString, whereObj);
|
||||
if (whereString.IsValuable())
|
||||
this.Where<T>(whereString, whereObj);
|
||||
return this;
|
||||
}
|
||||
public virtual ISugarQueryable<T> Where<T2>(string whereString, object whereObj = null)
|
||||
@ -793,7 +794,7 @@ namespace SqlSugar
|
||||
#region Order
|
||||
public ISugarQueryable<T, T2, T3> OrderBy(Expression<Func<T, T2, T3, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
_OrderBy(expression,type);
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -876,19 +877,19 @@ namespace SqlSugar
|
||||
#endregion
|
||||
|
||||
#region Aggr
|
||||
public TResult Max<TResult>(Expression<Func<T, T2,T3, TResult>> expression)
|
||||
{
|
||||
return _Max<TResult>(expression);
|
||||
}
|
||||
public TResult Min<TResult>(Expression<Func<T, T2,T3, TResult>> expression)
|
||||
{
|
||||
return _Min<TResult>(expression);
|
||||
}
|
||||
public TResult Sum<TResult>(Expression<Func<T, T2,T3, TResult>> expression)
|
||||
{
|
||||
return _Sum<TResult>(expression);
|
||||
}
|
||||
public TResult Avg<TResult>(Expression<Func<T, T2,T3, TResult>> expression)
|
||||
public TResult Max<TResult>(Expression<Func<T, T2, T3, TResult>> expression)
|
||||
{
|
||||
return _Max<TResult>(expression);
|
||||
}
|
||||
public TResult Min<TResult>(Expression<Func<T, T2, T3, TResult>> expression)
|
||||
{
|
||||
return _Min<TResult>(expression);
|
||||
}
|
||||
public TResult Sum<TResult>(Expression<Func<T, T2, T3, TResult>> expression)
|
||||
{
|
||||
return _Sum<TResult>(expression);
|
||||
}
|
||||
public TResult Avg<TResult>(Expression<Func<T, T2, T3, TResult>> expression)
|
||||
{
|
||||
return _Avg<TResult>(expression);
|
||||
}
|
||||
@ -1024,19 +1025,19 @@ namespace SqlSugar
|
||||
#endregion
|
||||
|
||||
#region Aggr
|
||||
public TResult Max<TResult>(Expression<Func<T, T2, T3,T4, TResult>> expression)
|
||||
{
|
||||
return _Max<TResult>(expression);
|
||||
}
|
||||
public TResult Min<TResult>(Expression<Func<T, T2, T3,T4, TResult>> expression)
|
||||
{
|
||||
return _Min<TResult>(expression);
|
||||
}
|
||||
public TResult Sum<TResult>(Expression<Func<T, T2, T3,T4, TResult>> expression)
|
||||
{
|
||||
return _Sum<TResult>(expression);
|
||||
}
|
||||
public TResult Avg<TResult>(Expression<Func<T, T2, T3,T4, TResult>> expression)
|
||||
public TResult Max<TResult>(Expression<Func<T, T2, T3, T4, TResult>> expression)
|
||||
{
|
||||
return _Max<TResult>(expression);
|
||||
}
|
||||
public TResult Min<TResult>(Expression<Func<T, T2, T3, T4, TResult>> expression)
|
||||
{
|
||||
return _Min<TResult>(expression);
|
||||
}
|
||||
public TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, TResult>> expression)
|
||||
{
|
||||
return _Sum<TResult>(expression);
|
||||
}
|
||||
public TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, TResult>> expression)
|
||||
{
|
||||
return _Avg<TResult>(expression);
|
||||
}
|
||||
@ -1198,19 +1199,19 @@ namespace SqlSugar
|
||||
#endregion
|
||||
|
||||
#region Aggr
|
||||
public TResult Max<TResult>(Expression<Func<T, T2, T3, T4,T5, TResult>> expression)
|
||||
{
|
||||
return _Max<TResult>(expression);
|
||||
}
|
||||
public TResult Min<TResult>(Expression<Func<T, T2, T3, T4,T5, TResult>> expression)
|
||||
{
|
||||
return _Min<TResult>(expression);
|
||||
}
|
||||
public TResult Sum<TResult>(Expression<Func<T, T2, T3, T4,T5, TResult>> expression)
|
||||
{
|
||||
return _Sum<TResult>(expression);
|
||||
}
|
||||
public TResult Avg<TResult>(Expression<Func<T, T2, T3, T4,T5, TResult>> expression)
|
||||
public TResult Max<TResult>(Expression<Func<T, T2, T3, T4, T5, TResult>> expression)
|
||||
{
|
||||
return _Max<TResult>(expression);
|
||||
}
|
||||
public TResult Min<TResult>(Expression<Func<T, T2, T3, T4, T5, TResult>> expression)
|
||||
{
|
||||
return _Min<TResult>(expression);
|
||||
}
|
||||
public TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, T5, TResult>> expression)
|
||||
{
|
||||
return _Sum<TResult>(expression);
|
||||
}
|
||||
public TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, T5, TResult>> expression)
|
||||
{
|
||||
return _Avg<TResult>(expression);
|
||||
}
|
||||
@ -1398,20 +1399,20 @@ namespace SqlSugar
|
||||
#endregion
|
||||
|
||||
#region Aggr
|
||||
public TResult Max<TResult>(Expression<Func<T, T2, T3, T4, T5,T6, TResult>> expression)
|
||||
{
|
||||
return _Max<TResult>(expression);
|
||||
}
|
||||
public TResult Min<TResult>(Expression<Func<T, T2, T3, T4, T5,T6, TResult>> expression)
|
||||
{
|
||||
return _Min<TResult>(expression);
|
||||
}
|
||||
public TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, T5,T6, TResult>> expression)
|
||||
{
|
||||
return _Sum<TResult>(expression);
|
||||
}
|
||||
public TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, T5,T6, TResult>> expression)
|
||||
{
|
||||
public TResult Max<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, TResult>> expression)
|
||||
{
|
||||
return _Max<TResult>(expression);
|
||||
}
|
||||
public TResult Min<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, TResult>> expression)
|
||||
{
|
||||
return _Min<TResult>(expression);
|
||||
}
|
||||
public TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, TResult>> expression)
|
||||
{
|
||||
return _Sum<TResult>(expression);
|
||||
}
|
||||
public TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, TResult>> expression)
|
||||
{
|
||||
return _Avg<TResult>(expression);
|
||||
}
|
||||
#endregion
|
||||
@ -1625,19 +1626,19 @@ namespace SqlSugar
|
||||
#endregion
|
||||
|
||||
#region Aggr
|
||||
public TResult Max<TResult>(Expression<Func<T, T2, T3, T4, T5, T6,T7, TResult>> expression)
|
||||
{
|
||||
return _Max<TResult>(expression);
|
||||
}
|
||||
public TResult Min<TResult>(Expression<Func<T, T2, T3, T4, T5, T6,T7, TResult>> expression)
|
||||
{
|
||||
return _Min<TResult>(expression);
|
||||
}
|
||||
public TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, T5, T6,T7, TResult>> expression)
|
||||
{
|
||||
return _Sum<TResult>(expression);
|
||||
}
|
||||
public TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, T5, T6,T7, TResult>> expression)
|
||||
public TResult Max<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, TResult>> expression)
|
||||
{
|
||||
return _Max<TResult>(expression);
|
||||
}
|
||||
public TResult Min<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, TResult>> expression)
|
||||
{
|
||||
return _Min<TResult>(expression);
|
||||
}
|
||||
public TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, TResult>> expression)
|
||||
{
|
||||
return _Sum<TResult>(expression);
|
||||
}
|
||||
public TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, TResult>> expression)
|
||||
{
|
||||
return _Avg<TResult>(expression);
|
||||
}
|
||||
@ -1878,19 +1879,19 @@ namespace SqlSugar
|
||||
#endregion
|
||||
|
||||
#region Aggr
|
||||
public TResult Max<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7,T8, TResult>> expression)
|
||||
{
|
||||
return _Max<TResult>(expression);
|
||||
}
|
||||
public TResult Min<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7,T8, TResult>> expression)
|
||||
{
|
||||
return _Min<TResult>(expression);
|
||||
}
|
||||
public TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7,T8, TResult>> expression)
|
||||
{
|
||||
return _Sum<TResult>(expression);
|
||||
}
|
||||
public TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7,T8, TResult>> expression)
|
||||
public TResult Max<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, TResult>> expression)
|
||||
{
|
||||
return _Max<TResult>(expression);
|
||||
}
|
||||
public TResult Min<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, TResult>> expression)
|
||||
{
|
||||
return _Min<TResult>(expression);
|
||||
}
|
||||
public TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, TResult>> expression)
|
||||
{
|
||||
return _Sum<TResult>(expression);
|
||||
}
|
||||
public TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, TResult>> expression)
|
||||
{
|
||||
return _Avg<TResult>(expression);
|
||||
}
|
||||
|
@ -270,5 +270,10 @@ namespace SqlSugar
|
||||
{
|
||||
return "( 1 = 2 ) ";
|
||||
}
|
||||
|
||||
public string GuidNew()
|
||||
{
|
||||
return "'"+Guid.NewGuid()+"' ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,5 +49,6 @@ namespace SqlSugar
|
||||
string MappingColumn(MethodCallExpressionModel model);
|
||||
string True();
|
||||
string False();
|
||||
string GuidNew();
|
||||
}
|
||||
}
|
||||
|
@ -235,6 +235,20 @@ namespace SqlSugar
|
||||
};
|
||||
return methodCallExpressionArgs;
|
||||
}
|
||||
|
||||
protected string GetNewExpressionValue(Expression item)
|
||||
{
|
||||
var newContext = this.Context.GetCopyContext();
|
||||
newContext.Resolve(item, this.Context.IsJoin ? ResolveExpressType.WhereMultiple : ResolveExpressType.WhereSingle);
|
||||
this.Context.Index = newContext.Index;
|
||||
this.Context.ParameterIndex = newContext.ParameterIndex;
|
||||
if (newContext.Parameters.IsValuable())
|
||||
{
|
||||
this.Context.Parameters.AddRange(newContext.Parameters);
|
||||
}
|
||||
return newContext.Result.GetResultString();
|
||||
}
|
||||
|
||||
protected void ResolveNewExpressions(ExpressionParameter parameter, Expression item, string asName)
|
||||
{
|
||||
if (item.NodeType == ExpressionType.Constant)
|
||||
|
@ -49,7 +49,13 @@ namespace SqlSugar
|
||||
MemberAssignment memberAssignment = (MemberAssignment)binding;
|
||||
var memberName = memberAssignment.Member.Name;
|
||||
var item = memberAssignment.Expression;
|
||||
if (item is UnaryExpression||item.NodeType == ExpressionType.Constant || (item is MemberExpression) && ((MemberExpression)item).Expression.NodeType == ExpressionType.Constant)
|
||||
if ((item is MemberExpression) && ((MemberExpression)item).Expression == null)
|
||||
{
|
||||
var paramterValue = ExpressionTool.DynamicInvoke(item);
|
||||
string parameterName = AppendParameter(paramterValue);
|
||||
this.Context.Result.Append(base.Context.GetEqString(memberName, parameterName));
|
||||
}
|
||||
else if (item is UnaryExpression || item.NodeType == ExpressionType.Constant || (item is MemberExpression) && ((MemberExpression)item).Expression.NodeType == ExpressionType.Constant)
|
||||
{
|
||||
base.Expression = item;
|
||||
base.Start();
|
||||
@ -80,7 +86,8 @@ namespace SqlSugar
|
||||
}
|
||||
else if (item is BinaryExpression)
|
||||
{
|
||||
Check.ThrowNotSupportedException(item.GetType().Name);
|
||||
var result=GetNewExpressionValue(item);
|
||||
this.Context.Result.Append(base.Context.GetEqString(memberName, result));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,13 +14,18 @@ namespace SqlSugar
|
||||
var express = base.Expression as MethodCallExpression;
|
||||
var isLeft = parameter.IsLeft;
|
||||
string methodName = express.Method.Name;
|
||||
if (methodName == "get_Item") {
|
||||
string paramterName =this.Context.SqlParameterKeyWord+ExpressionConst.Const + this.Context.ParameterIndex;
|
||||
if (methodName == "get_Item")
|
||||
{
|
||||
string paramterName = this.Context.SqlParameterKeyWord + ExpressionConst.Const + this.Context.ParameterIndex;
|
||||
this.Context.Parameters.Add(new SugarParameter(paramterName, ExpressionTool.DynamicInvoke(express)));
|
||||
this.Context.Result.Append(string.Format(" {0} ",paramterName));
|
||||
this.Context.Result.Append(string.Format(" {0} ", paramterName));
|
||||
this.Context.ParameterIndex++;
|
||||
return;
|
||||
}
|
||||
else if (methodName == "NewGuid") {
|
||||
this.Context.Result.Append(this.Context.DbMehtods.GuidNew());
|
||||
return;
|
||||
}
|
||||
var isValidNativeMethod = MethodMapping.ContainsKey(methodName)&&express.Method.DeclaringType.Namespace==("System");
|
||||
if (!isValidNativeMethod&&express.Method.DeclaringType.Namespace.IsIn("System.Linq", "System.Collections.Generic")&&methodName=="Contains") {
|
||||
methodName = "ContainsArray";
|
||||
|
@ -17,5 +17,5 @@ using System.Runtime.InteropServices;
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("1c022a5c-4e4d-4026-a8a3-f659b9740a1a")]
|
||||
[assembly: AssemblyVersion("4.2.0.3")]
|
||||
[assembly: AssemblyFileVersion("4.2.0.3")]
|
||||
[assembly: AssemblyVersion("4.2.0.4")]
|
||||
[assembly: AssemblyFileVersion("4.2.0.4")]
|
||||
|
@ -224,6 +224,25 @@ namespace SqlSugar
|
||||
queryable.Where(joinExpression);
|
||||
return queryable;
|
||||
}
|
||||
public virtual List<T> UnionAll<T>(params ISugarQueryable<T>[] queryables) where T : class, new()
|
||||
{
|
||||
if (queryables.IsNullOrEmpty()) return new List<T>();
|
||||
List<T> result = new List<T>();
|
||||
foreach (var item in queryables)
|
||||
{
|
||||
var addItems = item.ToList();
|
||||
if (addItems.IsValuable())
|
||||
{
|
||||
result.AddRange(addItems);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public virtual List<T> UnionAll<T>(List<ISugarQueryable<T>> queryables) where T : class, new()
|
||||
{
|
||||
if (queryables.IsNullOrEmpty()) return new List<T>();
|
||||
return UnionAll(queryables.ToArray());
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Insertable
|
||||
@ -259,7 +278,7 @@ namespace SqlSugar
|
||||
{
|
||||
return this.Deleteable<T>().In(primaryKeyValue);
|
||||
}
|
||||
public virtual IDeleteable<T> Deleteable<T>(dynamic [] primaryKeyValues) where T : class, new()
|
||||
public virtual IDeleteable<T> Deleteable<T>(dynamic[] primaryKeyValues) where T : class, new()
|
||||
{
|
||||
return this.Deleteable<T>().In(primaryKeyValues);
|
||||
}
|
||||
@ -383,7 +402,8 @@ namespace SqlSugar
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_SimpleClient == null) {
|
||||
if (_SimpleClient == null)
|
||||
{
|
||||
_SimpleClient = new SimpleClient(this);
|
||||
}
|
||||
return _SimpleClient;
|
||||
|
@ -2,7 +2,7 @@
|
||||
<package >
|
||||
<metadata>
|
||||
<id>sqlSugarCore</id>
|
||||
<version>4.2.0.3</version>
|
||||
<version>4.2.0.4</version>
|
||||
<authors>sunkaixuan</authors>
|
||||
<owners>Landa</owners>
|
||||
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>
|
||||
|
Loading…
Reference in New Issue
Block a user