CreateSqlElements() private method

递归解析表达式路由计算
private CreateSqlElements ( Expression exp, MemberType &type, bool isTure, bool isComparisonOperator = null ) : string
exp System.Linq.Expressions.Expression
type MemberType
isTure bool
isComparisonOperator bool
return string
示例#1
0
        public void ResolveExpression(ResolveExpress re, Expression exp)
        {
            ResolveExpress.MemberType type = ResolveExpress.MemberType.None;
            var expStr    = exp.ToString();
            var isNotBool = !expStr.Contains("True") && !expStr.Contains("False");

            if (isNotBool)
            {
                this.SqlWhere = string.Format(" AND {0} ", re.CreateSqlElements(exp, ref type));
            }
            else
            {
                var isTrue  = Regex.IsMatch(expStr, @"\=\> True$");
                var isFalse = Regex.IsMatch(expStr, @"\=\> False$");
                if (isFalse)
                {
                    this.SqlWhere = string.Format(" AND 1<>1 ");
                }
                else if (isTrue)
                {
                }
                else
                {
                    this.SqlWhere = string.Format(" AND {0} ", re.CreateSqlElements(exp, ref type));
                }
            }
        }
示例#2
0
        public void ResolveExpression(ResolveExpress re, Expression exp)
        {
            ResolveExpress.MemberType type = ResolveExpress.MemberType.None;
            var expStr        = exp.ToString();
            var isNotBool     = !expStr.Contains("True") && !expStr.Contains("False");
            var isContainsNot = expStr.Contains("Not");

            if (isContainsNot && expStr.IsMatch(@" => Not\(.+?\)"))
            {
                this.SqlWhere = string.Format(" AND {0}=0 or {0} is null ", Regex.Match(expStr, @" => Not\(.+\.(.+?)\)").Groups[1].Value);
            }
            else if (isNotBool)
            {
                this.SqlWhere = string.Format(" AND {0} ", re.CreateSqlElements(exp, ref type));
            }
            else
            {
                var isTrue  = Regex.IsMatch(expStr, @"\=\> True$");
                var isFalse = Regex.IsMatch(expStr, @"\=\> False$");
                if (isFalse)
                {
                    this.SqlWhere = string.Format(" AND 1<>1 ");
                }
                else if (isTrue)
                {
                }
                else
                {
                    this.SqlWhere = string.Format(" AND {0} ", re.CreateSqlElements(exp, ref type));
                }
            }
        }
示例#3
0
 /// <summary>
 /// 初始化表达式
 /// </summary>
 /// <param name="re"></param>
 /// <param name="exp"></param>
 private void Init(ResolveExpress re, Expression exp)
 {
     ResolveExpress.MemberType type = ResolveExpress.MemberType.None;
     //解析表达式
     this.SqlWhere = string.Format(" AND {0} ", re.CreateSqlElements(exp, ref type, true));
     //还原bool值
     foreach (var item in ConstantBoolDictionary)
     {
         if (this.SqlWhere.IsValuable())
         {
             this.SqlWhere = this.SqlWhere.Replace(item.Key.ToString(), item.ConditionalValue);
         }
     }
 }
示例#4
0
 public void ResolveExpression(ResolveExpress re, Expression exp)
 {
     ResolveExpress.MemberType type = ResolveExpress.MemberType.None;
     this.SqlWhere = string.Format(" AND {0} ", re.CreateSqlElements(exp, ref type));
 }
示例#5
0
 /// <summary>
 /// 初始化表达式
 /// </summary>
 /// <param name="re"></param>
 /// <param name="exp"></param>
 private void Init(ResolveExpress re, Expression exp)
 {
     ResolveExpress.MemberType type = ResolveExpress.MemberType.None;
     //解析表达式
     this.SqlWhere = string.Format(" AND {0} ", re.CreateSqlElements(exp, ref type,true));
     //还原bool值
     foreach (var item in ConstantBoolDictionary)
     {
         if (this.SqlWhere.IsValuable())
         {
             this.SqlWhere = this.SqlWhere.Replace(item.Key.ToString(), item.ConditionalValue);
         }
     }
 }
示例#6
0
 public void ResolveExpression(ResolveExpress re, Expression exp)
 {
     ResolveExpress.MemberType type = ResolveExpress.MemberType.None;
     this.SqlWhere = string.Format(" AND {0} ", re.CreateSqlElements(exp, ref type));
 }