コード例 #1
0
        private string Base(Expression exp)
        {
            var cached = (CachedExpression)exp;

            if (cached.Sql != null)
            {
                return(cached.Sql);
            }
            cached.Sql = exp switch
            {
                UnionExpression e => Union(e),
                SelectExpression e => Select(e),
                WhereExpression e => Where(e),
                MaxExpression e => Max(e),
                MinExpression e => Min(e),
                SumExpression e => Sum(e),
                CountExpression e => Count(e),
                TakeExpression e => Take(e),
                SkipExpression e => Skip(e),
                FirstExpression e => First(e),
                DistinctExpression e => Distinct(e),
                OrderByExpression e => OrderBy(e),
                OrderByDescendingExpression e => OrderByDescending(e),
                _ => throw new InvalidEnumArgumentException()
            };
            return(cached.Sql);
        }
コード例 #2
0
        private static Expression HandleMax(HandlerContext handlerContext)
        {
            var maxExpression
                = new MaxExpression(handlerContext.SelectExpression.Projection.Single());

            handlerContext.SelectExpression.SetProjectionExpression(maxExpression);

            return((Expression)_transformClientExpressionMethodInfo
                   .MakeGenericMethod(maxExpression.Type)
                   .Invoke(null, new object[] { handlerContext }));
        }
コード例 #3
0
ファイル: TestMath.cs プロジェクト: weihuajiang/WPF-Blocky
        public Completion Max(object a, object b)
        {
            ExecutionEnvironment e = new ExecutionEnvironment();

            e.RegisterValue("a", a);
            e.RegisterValue("b", b);
            MaxExpression abs = new MaxExpression();

            abs.Args[0] = new Identifier("a");
            abs.Args[1] = new Identifier("b");
            return(abs.Execute(e));
        }
コード例 #4
0
        public virtual Expression VisitMaxExpression(MaxExpression maxExpression)
        {
            Check.NotNull(maxExpression, "maxExpression");

            _sql.Append("MAX(");

            VisitExpression(maxExpression.ColumnExpression);

            _sql.Append(")");

            return(maxExpression);
        }
コード例 #5
0
        public virtual Expression VisitMax(MaxExpression maxExpression)
        {
            Check.NotNull(maxExpression, nameof(maxExpression));

            _sql.Append("MAX(");

            Visit(maxExpression.Expression);

            _sql.Append(")");

            return(maxExpression);
        }
コード例 #6
0
        public virtual Expression VisitMax(MaxExpression maxExpression)
        {
            Check.NotNull(maxExpression, nameof(maxExpression));

            _relationalCommandBuilder.Append("MAX(");

            Visit(maxExpression.Expression);

            _relationalCommandBuilder.Append(")");

            return(maxExpression);
        }
コード例 #7
0
 private string Max(MaxExpression exp) => $"SELECT MAX({Secondary.Serialize(exp.Selector.Body)}) FROM ({Serialize(exp.Sub)}) AS this";