mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-06-28 13:34:32 +08:00
Update Core
This commit is contained in:
parent
1e00e7e2f2
commit
b6e00f6e59
@ -266,7 +266,7 @@ namespace SqlSugar
|
||||
method = isNullableType ? getConvertDouble : getDouble;
|
||||
else
|
||||
method = isNullableType ? getConvertFloat : getFloat;
|
||||
if (dbTypeName == "float" && isNullableType && bindProperyTypeName == "single") {
|
||||
if (dbTypeName.Equals("float",StringComparison.CurrentCultureIgnoreCase) && isNullableType && bindProperyTypeName.Equals("single",StringComparison.CurrentCultureIgnoreCase)) {
|
||||
method = getConvertDoubleToFloat;
|
||||
}
|
||||
break;
|
||||
|
@ -44,5 +44,13 @@ namespace SqlSugar
|
||||
return ErrorMessage.GetThrowMessage("Join {0} needs to be the same as {1} {2}", "多表查询存在别名不一致,请把{1}中的{2}改成{0}就可以了,特殊需求可以使用.Select((x,y)=>new{{ id=x.id,name=y.name}}).MergeTable().Orderby(xxx=>xxx.Id)功能将Select中的多表结果集变成单表,这样就可以不限制别名一样");
|
||||
}
|
||||
}
|
||||
|
||||
public static string WhereIFCheck
|
||||
{
|
||||
get
|
||||
{
|
||||
return ErrorMessage.GetThrowMessage("Subquery.WhereIF.IsWhere {0} not supported", "Subquery.WhereIF 第一个参数不支持表达式中的变量,只支持外部变量");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,10 @@ namespace SqlSugar
|
||||
{
|
||||
base.Context.Result.Replace(ExpressionConst.FormatSymbol, ExpressionConst.LeftParenthesis + ExpressionConst.FormatSymbol);
|
||||
}
|
||||
if (leftExpression is UnaryExpression&& (leftExpression as UnaryExpression).Operand is UnaryExpression)
|
||||
{
|
||||
leftExpression = (leftExpression as UnaryExpression).Operand;
|
||||
}
|
||||
parameter.LeftExpression = leftExpression;
|
||||
parameter.RightExpression = rightExpression;
|
||||
base.Expression = leftExpression;
|
||||
@ -44,7 +48,7 @@ namespace SqlSugar
|
||||
if (lsbs && parameter.ValueIsNull)
|
||||
{
|
||||
base.Context.Result.Replace(ExpressionConst.ExpressionReplace + parameter.Index, isEqual ? "IS" : "IS NOT");
|
||||
base.Context.Result.Replace(ExpressionConst.ExpressionReplace + (parameter.Index+1), isEqual ? "IS" : "IS NOT");
|
||||
base.Context.Result.Replace(ExpressionConst.ExpressionReplace + (parameter.Index + 1), isEqual ? "IS" : "IS NOT");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -220,11 +220,11 @@ namespace SqlSugar
|
||||
}
|
||||
if (parameter.BaseParameter.BaseParameter.BaseParameter == null)
|
||||
{
|
||||
this.Context.Result.Append(GetMdthodValue(name, model));
|
||||
this.Context.Result.Append(GetMethodValue(name, model));
|
||||
}
|
||||
else
|
||||
{
|
||||
parameter.BaseParameter.CommonTempData = GetMdthodValue(name, model);
|
||||
parameter.BaseParameter.CommonTempData = GetMethodValue(name, model);
|
||||
}
|
||||
}
|
||||
private void Where(ExpressionParameter parameter, bool? isLeft, string name, IEnumerable<Expression> args, MethodCallExpressionModel model, List<MethodCallExpressionArgs> appendArgs = null)
|
||||
@ -241,7 +241,7 @@ namespace SqlSugar
|
||||
{
|
||||
model.Args.AddRange(appendArgs);
|
||||
}
|
||||
var methodValue = GetMdthodValue(name, model);
|
||||
var methodValue = GetMethodValue(name, model);
|
||||
if (parameter.BaseExpression is BinaryExpression && parameter.OppsiteExpression.Type == UtilConstants.BoolType&&name=="HasValue"&&!(parameter.OppsiteExpression is BinaryExpression)) {
|
||||
methodValue = this.Context.DbMehtods.CaseWhen(new List<KeyValuePair<string, string>>() {
|
||||
new KeyValuePair<string, string>("IF",methodValue.ObjToString()),
|
||||
@ -385,7 +385,7 @@ namespace SqlSugar
|
||||
parameter.ChildExpression = null;
|
||||
}
|
||||
|
||||
private object GetMdthodValue(string name, MethodCallExpressionModel model)
|
||||
private object GetMethodValue(string name, MethodCallExpressionModel model)
|
||||
{
|
||||
if (IsExtMethod(name))
|
||||
{
|
||||
|
@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
public class SubWhereIF : ISubOperation
|
||||
{
|
||||
public bool HasWhere
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "WhereIF"; }
|
||||
}
|
||||
|
||||
public Expression Expression
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public int Sort
|
||||
{
|
||||
get
|
||||
{
|
||||
return 400;
|
||||
}
|
||||
}
|
||||
|
||||
public ExpressionContext Context
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public string GetValue(Expression expression)
|
||||
{
|
||||
var exp = expression as MethodCallExpression;
|
||||
object value = null;
|
||||
try
|
||||
{
|
||||
value = ExpressionTool.DynamicInvoke(exp.Arguments[0]);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Check.Exception(true, ErrorMessage.WhereIFCheck,exp.Arguments[0].ToString());
|
||||
}
|
||||
var isWhere= Convert.ToBoolean(value);
|
||||
if (!Convert.ToBoolean(isWhere)) {
|
||||
return "";
|
||||
}
|
||||
var argExp = exp.Arguments[1];
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@ namespace SqlSugar
|
||||
{
|
||||
new SubSelect() { Context=Context },
|
||||
new SubWhere(){ Context=Context },
|
||||
new SubWhereIF(){ Context=Context },
|
||||
new SubAnd(){ Context=Context },
|
||||
new SubAny(){ Context=Context },
|
||||
new SubNotAny(){ Context=Context },
|
||||
|
@ -13,6 +13,10 @@ namespace SqlSugar
|
||||
{
|
||||
return this;
|
||||
}
|
||||
public Subqueryable<T> WhereIF(bool isWhere,Func<T, bool> expression)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
public Subqueryable<T> OrderBy(Func<T, object> expression)
|
||||
{
|
||||
return this;
|
||||
|
Loading…
Reference in New Issue
Block a user