コード例 #1
0
ファイル: QueryVisitor.cs プロジェクト: cjdtppmm/PChou
        protected override Expression VisitMethodCall(MethodCallExpression m)
        {
            if (m.Method.DeclaringType == typeof(Queryable) && m.Method.Name == "Where")
            {
                this.Visit(m.Arguments[0]);
                LambdaExpression           lambda       = (LambdaExpression)StripQuotes(m.Arguments[1]);
                ConditionExpressionVisitor whereVisitor = new ConditionExpressionVisitor();
                whereVisitor.Translate(lambda.Body, tr);
                return(m);
            }
            else if (m.Method.DeclaringType == typeof(Queryable) && m.Method.Name == "Select")
            {
                this.Visit(m.Arguments[0]);
                LambdaExpression        lambda        = (LambdaExpression)StripQuotes(m.Arguments[1]);
                SelectExpressionVisitor selectVisitor = new SelectExpressionVisitor();
                selectVisitor.Translate(lambda, tr);
                return(m);
            }
            else if (m.Method.DeclaringType == typeof(Queryable) && m.Method.Name == "Count")
            {
                tr.HasStatictisc  = true;
                tr.StatictiscVerb = "Count";
                this.Visit(m.Arguments[0]);
                if (m.Arguments.Count == 2)
                {
                    throw new NotSupportedException("Count clause not support parameter,use where clause instead.");
                }
                return(m);
            }
            else if (m.Method.DeclaringType == typeof(Queryable) && (m.Method.Name == "OrderByDescending" || m.Method.Name == "OrderBy"))
            {
                Visit(m.Arguments[0]);
                LambdaExpression         lambda       = (LambdaExpression)StripQuotes(m.Arguments[1]);
                OrderByExpressionVisitor orderVisitor = new OrderByExpressionVisitor(m.Method.Name);
                orderVisitor.Translate(lambda.Body, tr);
                return(m);
            }
            else if (m.Method.Name == "Sum" ||
                     m.Method.Name == "Average" ||
                     m.Method.Name == "Max" ||
                     m.Method.Name == "Min" ||
                     m.Method.Name == "Count")
            {
                throw new NotSupportedException("Statictisc is not support yet.");
            }

            else if (m.Method.Name == "GroupBy")
            {
                throw new NotSupportedException("GroupBy is not support yet.");
            }
            throw new NotSupportedException(string.Format("The method '{0}' is not supported", m.Method.Name));
        }
コード例 #2
0
ファイル: QueryVisitor.cs プロジェクト: qianxuecheng/NRemedy
        protected override Expression VisitMethodCall(MethodCallExpression m)
        {
            if (m.Method.DeclaringType == typeof(Queryable) && m.Method.Name == "Where") {

                this.Visit(m.Arguments[0]);
                LambdaExpression lambda = (LambdaExpression)StripQuotes(m.Arguments[1]);
                ConditionExpressionVisitor whereVisitor = new ConditionExpressionVisitor();
                whereVisitor.Translate(lambda.Body, tr);
                return m;
            }
            else if (m.Method.DeclaringType == typeof(Queryable) && m.Method.Name == "Select")
            {
                this.Visit(m.Arguments[0]);
                LambdaExpression lambda = (LambdaExpression)StripQuotes(m.Arguments[1]);
                SelectExpressionVisitor selectVisitor = new SelectExpressionVisitor();
                selectVisitor.Translate(lambda,tr);
                return m;
            }
            else if (m.Method.DeclaringType == typeof(Queryable) && m.Method.Name == "Count")
            {
                tr.HasStatictisc = true;
                tr.StatictiscVerb = "Count";
                this.Visit(m.Arguments[0]);
                if (m.Arguments.Count == 2)
                {
                    throw new NotSupportedException("Count clause not support parameter,use where clause instead.");
                }
                return m;
            }
            else if (m.Method.DeclaringType == typeof(Queryable) && (m.Method.Name == "OrderByDescending" || m.Method.Name == "OrderBy"))
            {
                Visit(m.Arguments[0]);
                LambdaExpression lambda = (LambdaExpression)StripQuotes(m.Arguments[1]);
                OrderByExpressionVisitor orderVisitor = new OrderByExpressionVisitor(m.Method.Name);
                orderVisitor.Translate(lambda.Body,tr);
                return m;
            }
            else if (m.Method.Name == "Sum"
                || m.Method.Name == "Average"
                || m.Method.Name == "Max"
                || m.Method.Name == "Min"
                || m.Method.Name == "Count")
            {
                throw new NotSupportedException("Statictisc is not support yet.");
            }

            else if (m.Method.Name == "GroupBy")
            {
                throw new NotSupportedException("GroupBy is not support yet.");
            }
            throw new NotSupportedException(string.Format("The method '{0}' is not supported", m.Method.Name));
        }
コード例 #3
0
        public static void DeleteEntryList <TModel>(this ARProxy <TModel> proxy, Expression <Func <TModel, bool> > expression)
            where TModel : ARBaseForm
        {
            if (expression == null)
            {
                throw new ArgumentNullException("expression must not null. If want to delete all entries, try to use m => true");
            }
            ConditionExpressionVisitor visitor = new ConditionExpressionVisitor();
            var             expEvaled          = Evaluator.PartialEval(expression);
            ConditionResult tr = visitor.Translate(expEvaled);
            string          qu = tr.Qulification == null ? null : tr.Qulification.ToString();

            proxy.DeleteEntryList(qu);
        }
コード例 #4
0
        public static IList <TModel> GetEntryList <TModel>(this ARProxy <TModel> proxy,
                                                           Expression <Func <TModel, bool> > expression,
                                                           uint StartIndex,
                                                           uint?RetrieveCount,
                                                           TotalMatch totalMatch,
                                                           List <ARSortInfo> sortInfo,
                                                           params Expression <Func <TModel, object> >[] propertiesTobeUp)
            where TModel : ARBaseForm
        {
            if (expression == null)
            {
                throw new ArgumentNullException("expression must not null. If want to delete all entries, try to use m => true");
            }
            ConditionExpressionVisitor visitor = new ConditionExpressionVisitor();
            var             expEvaled          = Evaluator.PartialEval(expression);
            ConditionResult tr = visitor.Translate(expEvaled);
            string          qu = tr.Qulification == null ? null : tr.Qulification.ToString();

            return(GetEntryList(proxy, qu, StartIndex, RetrieveCount, totalMatch, sortInfo, propertiesTobeUp));
        }