当前位置: 首页>>代码示例>>C#>>正文


C# Sql.Expression类代码示例

本文整理汇总了C#中Deveel.Data.Sql.Expression的典型用法代码示例。如果您正苦于以下问题:C# Expression类的具体用法?C# Expression怎么用?C# Expression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Expression类属于Deveel.Data.Sql命名空间,在下文中一共展示了Expression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EvaluateAggregate

        public ITable EvaluateAggregate(QueryProcessor processor, bool distinct, ITable group, Expression[] args)
        {
            if (!function.IsAggregate)
                throw new InvalidOperationException("The function is not an aggregate.");

            try {
                // Execute it
                object[] funArgs;
                if (invokeType == 6) {
                    funArgs = new object[] { function.Name, processor, distinct, group, args };
                }
                    // The QueryProcessor, Expression[] construct
                else if (invokeType == 1) {
                    funArgs = new object[] { processor, distinct, group, args };
                } else {
                    throw new ApplicationException("Unknown invoke type");
                }

                return (ITable)method.Invoke(null, funArgs);
            } catch (MethodAccessException e) {
                throw new ApplicationException(e.Message, e);
            } catch (TargetInvocationException e) {
                throw new ApplicationException(e.InnerException.Message, e.InnerException);
            }
        }
开发者ID:ikvm,项目名称:deveelsql,代码行数:25,代码来源:ReflectionFunctionEvaluationContext.cs

示例2: If

 public static ITable If(QueryProcessor processor, Expression[] args)
 {
     SqlObject[] conditional = QueryProcessor.Result(processor.Execute(args[0]));
     // If it evaluated to true,
     bool? b = conditional[0].Value.ToBoolean();
     return b != null && b == true ? processor.Execute(args[1]) : processor.Execute(args[2]);
 }
开发者ID:ikvm,项目名称:deveelsql,代码行数:7,代码来源:SystemFunctions.cs

示例3: Length

        public static ITable Length(QueryProcessor processor, Expression[] args)
        {
            if (args.Length != 1)
                throw new ArgumentException("The function LENGTH accepts only 1 argument.");

            Expression arg = args[0];

            SqlObject resultLength;
            SqlObject obj = QueryProcessor.Result(processor.Execute(arg))[0];
            if (obj.IsNull) {
                resultLength = SqlObject.MakeNull(SqlType.Numeric);
            } else {
                int length;
                SqlType obType = obj.Type;
                SqlValue obValue = obj.Value;
                // If it's a string,
                if (obType.IsString) {
                    length = obValue.ToString().Length;
                }
                    // If it's a binary,
                else if (obType.IsBinary) {
                    length = obValue.Length - 1;
                }
                    // Otherwise, return null,
                else {
                    length = -1;
                }

                resultLength = length == -1 ? SqlObject.MakeNull(SqlType.Numeric) : new SqlObject((long) length);
            }

            return QueryProcessor.ResultTable(resultLength);
        }
开发者ID:ikvm,项目名称:deveelsql,代码行数:33,代码来源:SystemFunctions.cs

示例4: FilterExpression

 public FilterExpression(string name, Expression child, Expression filter)
     : base(ExpressionType.Filter)
 {
     SetArgument("name", name);
     SetArgument("child", child);
     SetArgument("filter", filter);
 }
开发者ID:ikvm,项目名称:deveelsql,代码行数:7,代码来源:FilterExpression.cs

示例5: GroupConcat

        public static ITable GroupConcat(QueryProcessor processor, bool distinct, ITable group, Expression[] args)
        {
            // The output string
            StringBuilder return_string = new StringBuilder();

            // Find the distinct subset of group
            if (distinct)
                group = processor.DistinctSubset(group, args);

            // Push the group table onto the processor stack
            processor.PushTable(group);

            // Iterator over the group
            IRowCursor i = group.GetRowCursor();
            bool first = true;
            while (i.MoveNext()) {
                RowId rowid = i.Current;
                processor.UpdateTableRow(rowid);
                foreach (Expression op in args) {
                    ITable val = processor.Execute(op);
                    SqlObject ob = QueryProcessor.Result(val)[0];
                    if (!ob.IsNull) {
                        if (!first) {
                            return_string.Append(", ");
                        }
                        return_string.Append(SqlValue.FromObject(ob.Value).ToString());
                        first = false;
                    }
                }
            }

            // Pop the table and return the result
            processor.PopTable();
            return QueryProcessor.ResultTable(new SqlObject(return_string.ToString()));
        }
开发者ID:ikvm,项目名称:deveelsql,代码行数:35,代码来源:SystemFunctions_Aggregate.cs

示例6: AliasTableNameExpression

 public AliasTableNameExpression(Expression child, TableName alias, SqlType returnType)
     : base(ExpressionType.AliasTableName)
 {
     SetArgument("child", child);
     SetArgument("alias", alias);
     if (returnType != null)
         SetArgument("return_type", returnType);
 }
开发者ID:ikvm,项目名称:deveelsql,代码行数:8,代码来源:AliasTableNameExpression.cs

示例7: Avg

        public static ITable Avg(QueryProcessor processor, bool distinct, ITable group, Expression[] args)
        {
            // Aggregate function only can have 1 argument
            if (args.Length > 1)
                throw new ArgumentException("Only one argument permitted for SUM function.");

            return ProcessAggregate(processor, distinct, group, args, new AvgAggregateInspector());
        }
开发者ID:ikvm,项目名称:deveelsql,代码行数:8,代码来源:SystemFunctions_Aggregate.cs

示例8: GetActionString

 private static string GetActionString(Expression expression)
 {
     if (expression is FetchStaticExpression) {
         SqlObject val = (SqlObject)expression.GetArgument("static");
         return val.ToString();
     }
     throw new ApplicationException("Expecting static expression");
 }
开发者ID:ikvm,项目名称:deveelsql,代码行数:8,代码来源:SqlInterpreter_DDL.cs

示例9: JoinExpression

 public JoinExpression(Expression left, Expression right, JoinType type, Expression filter)
     : this()
 {
     SetArgument("left", left);
     SetArgument("right", right);
     SetArgument("type", type);
     if (filter != null)
         SetArgument("filter", filter);
 }
开发者ID:ikvm,项目名称:deveelsql,代码行数:9,代码来源:JoinExpression.cs

示例10: UpdatableResultSetView

 public UpdatableResultSetView(SystemTransaction transaction, IMutableTable backedTable, Expression[] project, IRowCursor select)
 {
     this.transaction = transaction;
     this.backedTable = backedTable;
     this.project = project;
     originalSelect = select;
     currentSelect = select;
     this.select = null;
 }
开发者ID:ikvm,项目名称:deveelsql,代码行数:9,代码来源:UpdatableResultSetView.cs

示例11: WalkGraph

        public static Expression WalkGraph(Expression op, IGraphInspector inspector)
        {
            // The pre walk call
            op = inspector.OnBeforeWalk(op);

            ExpressionType type = op.Type;
            switch (type) {
                case ExpressionType.Function:
                    InspectParamList(inspector, op, "param_count", "arg");
                    break;

                case ExpressionType.Select:
                    InspectParam(inspector, op, "join");
                    InspectParam(inspector, op, "filter");
                    InspectParam(inspector, op, "havingfilter");
                    InspectParamList(inspector, op, "out_count", "out");
                    InspectParamList(inspector, op, "groupby_count", "groupby");
                    InspectParamList(inspector, op, "orderby_count", "orderby");
                    break;

                case ExpressionType.Join:
                    InspectParam(inspector, op, "left");
                    InspectParam(inspector, op, "right");
                    InspectParam(inspector, op, "filter");
                    break;

                // Single passthrough
                case ExpressionType.AliasTableName:
                case ExpressionType.AliasVariableName:
                    InspectParam(inspector, op, "child");
                    break;
                case ExpressionType.Filter:
                    InspectParam(inspector, op, "child");
                    InspectParam(inspector, op, "filter");
                    break;

                // Terminators
                case ExpressionType.FetchVariable:
                case ExpressionType.FetchStatic:
                case ExpressionType.FetchParameter:
                case ExpressionType.FetchGlob:
                case ExpressionType.FetchTable:
                    break;

                default:
                    throw new ArgumentException("Unknown operation " + op.Type);
            }

            // The post expression call
            op = inspector.OnAfterWalk(op);

            // Return the operation
            return op;
        }
开发者ID:ikvm,项目名称:deveelsql,代码行数:54,代码来源:QueryOptimizer.cs

示例12: Evaluate

        public ITable Evaluate(QueryProcessor processor, Expression[] args)
        {
            // 'CAST' is a special case,
            if (function.Name.Equals("@cast")) {
                // Get the value to cast, and the type to cast it to,
                SqlObject val = QueryProcessor.Result(processor.Execute(args[0]))[0];
                SqlObject castType = QueryProcessor.Result(processor.Execute(args[1]))[0];

                string castTypeString = castType.Value.ToString();
                SqlType type = SqlType.Parse(castTypeString);

                // Do the cast,
                SqlObject result = val.CastTo(type);

                // And return the result,
                return QueryProcessor.ResultTable(result);
            }

            if (function.IsAggregate)
                throw new InvalidOperationException("The function is aggregate.");

            try {
                // Execute it
                if (invokeType == 6) {
                    object[] funArgs = { function.Name, processor, args };
                    return (ITable)method.Invoke(null, funArgs);
                }
                    // The QueryProcessor, Expression[] construct
                if (invokeType == 1) {
                    object[] funArgs = { processor, args };
                    return (ITable)method.Invoke(null, funArgs);
                }
                    // The SqlObject construct
                if (invokeType == 2) {
                    int sz = args.Length;
                    // Resolve the arguments into TypedValues
                    SqlObject[] obs = new SqlObject[sz];
                    for (int i = 0; i < sz; ++i) {
                        obs[i] = QueryProcessor.Result(processor.Execute(args[i]))[0];
                    }
                    // Set up the arguments and invoke the method
                    object[] funArgs = { obs };
                    SqlObject result = (SqlObject)method.Invoke(null, funArgs);
                    // Wrap on a FunctionTable and return
                    return QueryProcessor.ResultTable(result);
                }

                throw new ApplicationException("Unknown invoke type");
            } catch (MethodAccessException e) {
                throw new ApplicationException(e.Message, e);
            } catch (TargetInvocationException e) {
                throw new ApplicationException(e.InnerException.Message, e.InnerException);
            }
        }
开发者ID:ikvm,项目名称:deveelsql,代码行数:54,代码来源:ReflectionFunctionEvaluationContext.cs

示例13: CostAggregateFilterOp

        private static void CostAggregateFilterOp(Expression child, FilterExpression expression)
        {
            // The child cost values
            double childRows = child.CostRows;
            double childTime = child.CostTime;

            // TODO: We should check for full range aggregate, in which case we
            //   know there will only be 1 row result.

            // Set the costs
            expression.CostTime = childTime + (childRows * 1);
            expression.CostRows = childRows;
        }
开发者ID:ikvm,项目名称:deveelsql,代码行数:13,代码来源:QueryCostModel_Filter.cs

示例14: Least

        public static ITable Least(QueryProcessor processor, Expression[] args)
        {
            SqlObject least = null;
            for (int i = 0; i < args.Length; ++i) {
                SqlObject ob = QueryProcessor.Result(processor.Execute(args[i]))[0];
                if (ob.IsNull)
                    return QueryProcessor.ResultTable(ob);

                if (least == null || SqlObject.Compare(ob, least) < 0)
                    least = ob;
            }

            return QueryProcessor.ResultTable(least);
        }
开发者ID:ikvm,项目名称:deveelsql,代码行数:14,代码来源:SystemFunctions.cs

示例15: Cost

        public void Cost(Expression expression, double currentBestTime, int[] walkIteration)
        {
            // If this already has costing information, return
            if (expression.IsCostSet)
                return;

            ++walkIteration[0];

            if (expression is FilterExpression) {
                // Cost the child
                Expression childExp = ((FilterExpression)expression).Child;
                Cost(childExp, currentBestTime, walkIteration);
                if (!childExp.IsCostSet ||
                    IsCostWorse(currentBestTime, childExp)) {
                    return;
                }

                // Cost the filter operation
                CostFilterExpression(childExp, expression);
            } else if (expression is JoinExpression) {
                JoinExpression joinExp = (JoinExpression) expression;

                // Cost the left and right operations
                Expression left = joinExp.Left;
                Expression right = joinExp.Right;

                Cost(left, currentBestTime, walkIteration);
                if (!left.IsCostSet || IsCostWorse(currentBestTime, left))
                    return;

                Cost(right, currentBestTime, walkIteration);
                if (!right.IsCostSet || IsCostWorse(currentBestTime, right))
                    return;

                // Cost the join operation
                CostJoinExpression(left, right, joinExp);
            } else if (expression is AliasTableNameExpression) {
                // Fetch the table, apply the alias, and update the cost information.
                // The cost in time is 0 for a fetch operation because no scan operations
                // are necessary.
                ITable table = ExecuteExpression(expression);
                expression.CostTime = 0;
                expression.CostRows = table.RowCount;
            } else if (expression is FunctionExpression) {
                // Function should already be costed
                return;
            } else {
                throw new ApplicationException("Unrecognized operation type");
            }
        }
开发者ID:ikvm,项目名称:deveelsql,代码行数:50,代码来源:QueryCostModel.cs


注:本文中的Deveel.Data.Sql.Expression类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。