Ejemplo n.º 1
0
        public string IsNullOrEmpty(CRLExpression.MethodCallObj methodInfo, ref int parIndex, AddParameHandler addParame)
        {
            var field  = methodInfo.MemberQueryName;
            var isNot  = methodInfo.ExpressionType == ExpressionType.Not;
            var notStr = dBAdapter.IsNotFormat(isNot);
            var result = string.Format("({0} {1} null {3} {0}{2}'')", field, notStr, isNot ? "!=" : "=", isNot ? "and" : "or");

            return(result);
        }
Ejemplo n.º 2
0
        CRLExpression.CRLExpression DealParame(CRLExpression.CRLExpression par1, string typeStr)
        {
            var par = par1.Data + "";

            //typeStr2 = typeStr;
            //todo 非关系型数据库不参数化
            if (dbContext.DataBaseArchitecture == DataBaseArchitecture.NotRelation)
            {
                return(par1);
            }
            if (parIndex > 1000)
            {
                throw new CRLException("参数计数超过了1000,请确认数据访问对象没有被静态化");
            }
            switch (par1.Type)
            {
            case CRLExpression.CRLExpressionType.Value:
                #region value
                if (par1.Data == null)
                {
                    par = __DBAdapter.IsNotFormat(typeStr != "=") + "null";
                }
                else
                {
                    QueryParames.Add("par" + parIndex, par);
                    par       = "@par" + parIndex;
                    parIndex += 1;
                }
                #endregion
                break;

            case CRLExpression.CRLExpressionType.MethodCall:
                #region method
                var method = par1.Data as CRLExpression.MethodCallObj;
                var dic    = MethodAnalyze.GetMethos(__DBAdapter);
                if (!dic.ContainsKey(method.MethodName))
                {
                    throw new CRLException("LambdaQuery不支持扩展方法" + method.MemberQueryName + "." + method.MethodName);
                }
                int newParIndex = parIndex;
                par      = dic[method.MethodName](method, ref newParIndex, AddParame);
                parIndex = newParIndex;
                #endregion
                break;
            }
            par1.DataParamed = par;
            return(par1);
        }