Esempio n. 1
0
        private DicModel NewCollectionIn(ExpressionType nodeType, Expression keyExpr, Expression valExpr)
        {
            if (nodeType == ExpressionType.NewArrayInit)
            {
                var naExpr   = valExpr as NewArrayExpression;
                var keyTuple = GetKey(keyExpr, OptionEnum.In);
                var vals     = new List <string>();
                foreach (var exp in naExpr.Expressions)
                {
                    vals.Add(DC.VH.GetConstantVal(exp as ConstantExpression, keyTuple.valType));
                }

                var val = string.Join(",", vals);
                return(DicHandle.CallInHandle(keyTuple.key, keyTuple.alias, val, keyTuple.valType));
            }
            else if (nodeType == ExpressionType.ListInit)
            {
                var liExpr   = valExpr as ListInitExpression;
                var keyTuple = GetKey(keyExpr, OptionEnum.In);
                var vals     = new List <string>();
                foreach (var ini in liExpr.Initializers)
                {
                    var arg = ini.Arguments[0];
                    vals.Add(DC.VH.GetConstantVal(ini.Arguments[0] as ConstantExpression, keyTuple.valType));
                }

                var val = string.Join(",", vals);
                return(DicHandle.CallInHandle(keyTuple.key, keyTuple.alias, val, keyTuple.valType));
            }

            return(null);
        }
Esempio n. 2
0
        private DicModel CollectionIn(Expression expr, MemberExpression memExpr)
        {
            var keyTuple = GetKey(expr, OptionEnum.In);
            var val      = HandMember(memExpr);

            return(DicHandle.CallInHandle(keyTuple.key, keyTuple.alias, val, keyTuple.valType));
        }
Esempio n. 3
0
        private DicModel HandConditionMemberAccess(MemberExpression memExpr)
        {
            var tuple = GetMemTuple(memExpr);

            if (tuple.valType == typeof(bool))
            {
                return(DicHandle.MemberBoolHandle(tuple.key, tuple.alias, tuple.valType));
            }

            return(null);
        }
Esempio n. 4
0
        private DicModel HandConditionConstant(ConstantExpression cExpr)
        {
            var valType = cExpr.Type;
            var val     = DC.VH.GetConstantVal(cExpr, valType);

            if (cExpr.Type == typeof(bool))
            {
                return(DicHandle.ConstantBoolHandle(val, valType));
            }

            return(null);
        }
Esempio n. 5
0
        /********************************************************************************************************************/

        private DicModel HandOnBinary(BinaryExpression binExpr)
        {
            var option = OptionEnum.Compare;
            var tuple1 = GetKey(binExpr.Left, option);
            var tuple2 = GetKey(binExpr.Right, option);

            return(new DicModel
            {
                ColumnOne = tuple1.key,
                TableAliasOne = tuple1.alias,
                KeyTwo = tuple2.key,
                AliasTwo = tuple2.alias,
                Option = option,
                Compare = DicHandle.GetOption(binExpr.NodeType, false)
            });
        }
Esempio n. 6
0
        /********************************************************************************************************************/

        private DicModel HandConditionBinary(BinaryExpression binExpr, List <string> pres)
        {
            var binTuple = HandBinExpr(pres, binExpr);
            var val      = HandBinary(binTuple.right);
            var leftStr  = binTuple.left.ToString();

            if (leftStr.Contains(".Length") &&
                leftStr.IndexOf(".") < leftStr.LastIndexOf("."))
            {
                var keyTuple = GetKey(binTuple.left, OptionEnum.CharLength);
                return(DicHandle.BinaryCharLengthHandle(keyTuple.key, keyTuple.alias, val, keyTuple.valType, binTuple.node, binTuple.isR));
            }
            else
            {
                var keyTuple = GetKey(binTuple.left, OptionEnum.Compare /*DicHandle.GetOption(binTuple.node, binTuple.isR)*/);
                return(DicHandle.BinaryNormalHandle(keyTuple.key, keyTuple.alias, val, keyTuple.valType, binTuple.node, binTuple.isR));
            }
        }
Esempio n. 7
0
        /********************************************************************************************************************/

        private DicModel StringLike(MethodCallExpression mcExpr, StringLikeEnum type)
        {
            if (mcExpr.Object == null)
            {
                return(null);
            }
            else
            {
                var objExpr     = mcExpr.Object;
                var objNodeType = mcExpr.Object.NodeType;
                if (objNodeType == ExpressionType.MemberAccess)
                {
                    var memO    = objExpr as MemberExpression;
                    var memType = objExpr.Type;
                    if (memType == typeof(string))
                    {
                        var keyTuple = GetKey(memO, OptionEnum.Like);
                        var val      = string.Empty;
                        switch (type)
                        {
                        case StringLikeEnum.Contains:
                            val = DC.VH.GetCallVal(mcExpr);
                            break;

                        case StringLikeEnum.StartsWith:
                            val = $"{DC.VH.GetCallVal(mcExpr)}%";
                            break;

                        case StringLikeEnum.EndsWith:
                            val = $"%{DC.VH.GetCallVal(mcExpr)}";
                            break;
                        }
                        return(DicHandle.CallLikeHandle(keyTuple.key, keyTuple.alias, val, keyTuple.valType));
                    }
                }
            }

            return(null);
        }
        private DicModel HandConditionCall(MethodCallExpression mcExpr)
        {
            var exprStr = mcExpr.ToString();

            if (exprStr.Contains(".Contains("))
            {
                if (mcExpr.Object == null)
                {
                    var memKey = mcExpr.Arguments[1];
                    var memVal = mcExpr.Arguments[0];
                    if (memVal.NodeType == ExpressionType.MemberAccess)
                    {
                        var keyTuple = GetKey(memKey, OptionEnum.In);
                        var val      = HandMember(memVal as MemberExpression);
                        return(DicHandle.CallInHandle(keyTuple.key, keyTuple.alias, val, keyTuple.valType));
                    }
                    else if (memVal.NodeType == ExpressionType.NewArrayInit)
                    {
                        var naExpr   = memVal as NewArrayExpression;
                        var keyTuple = GetKey(memKey, OptionEnum.In);
                        var vals     = new List <string>();
                        foreach (var exp in naExpr.Expressions)
                        {
                            vals.Add(DC.VH.GetConstantVal(exp as ConstantExpression, keyTuple.valType));
                        }
                        var val = string.Join(",", vals);
                        return(DicHandle.CallInHandle(keyTuple.key, keyTuple.alias, val, keyTuple.valType));
                    }
                }
                else
                {
                    var objExpr     = mcExpr.Object;
                    var objNodeType = mcExpr.Object.NodeType;
                    if (objNodeType == ExpressionType.MemberAccess)
                    {
                        var memO    = objExpr as MemberExpression;
                        var memType = objExpr.Type;
                        if (memType.GetInterfaces() != null &&
                            memType.GetInterfaces().Contains(typeof(IList)) &&
                            !memType.IsArray)
                        {
                            var val      = HandMember(memO);
                            var keyTuple = GetKey(mcExpr, OptionEnum.In);
                            return(DicHandle.CallInHandle(keyTuple.key, keyTuple.alias, val, keyTuple.valType));
                        }
                        else if (memType == typeof(string))
                        {
                            var keyTuple = GetKey(memO, OptionEnum.Like);
                            var val      = DC.VH.GetCallVal(mcExpr);
                            return(DicHandle.CallLikeHandle(keyTuple.key, keyTuple.alias, val, keyTuple.valType));
                        }
                    }
                    else if (objNodeType == ExpressionType.ListInit)
                    {
                        var liExpr   = objExpr as ListInitExpression;
                        var keyTuple = GetKey(mcExpr, OptionEnum.In);
                        var vals     = new List <string>();
                        foreach (var ini in liExpr.Initializers)
                        {
                            var arg = ini.Arguments[0];
                            vals.Add(DC.VH.GetConstantVal(ini.Arguments[0] as ConstantExpression, keyTuple.valType));
                        }
                        var val = string.Join(",", vals);
                        return(DicHandle.CallInHandle(keyTuple.key, keyTuple.alias, val, keyTuple.valType));
                    }
                }
            }

            return(null);
        }