• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Sql.Expression类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: AddColumn

        public void AddColumn(string label, SqlType type, Expression expr)
        {
            OutputExpression outExpr = new OutputExpression();
            outExpr.label = label;
            outExpr.type = type;
            outExpr.expression = expr;
            // If the expression is a 'FETCHVAR' type then we pass it through the
            // blob accessor methods in hopes of not having to materialize large
            // objects.
            if (expr is FetchVariableExpression)
                outExpr.var = ((FetchVariableExpression)expr).Variable;

            outputExps.Add(outExpr);
        }
开发者ID:ikvm,项目名称:deveelsql,代码行数:14,代码来源:ExpressionTable.cs


示例17: IsDeferrable

        private static bool IsDeferrable(Expression op)
        {
            if (op is FetchStaticExpression) {
                SqlObject val = (SqlObject)op.GetArgument("static");
                string str = val.ToString();
                if (str.Equals("deferrable"))
                    return true;
                if (str.Equals("not deferrable"))
                    return false;

                throw new ApplicationException("Unexpected deferrability type '" + str + "'");
            }

            throw new ApplicationException("Expecting static expression");
        }
开发者ID:ikvm,项目名称:deveelsql,代码行数:15,代码来源:SqlInterpreter_DDL.cs


示例18: IsDeferred

        private static bool IsDeferred(Expression expression)
        {
            if (expression is FetchStaticExpression) {
                SqlObject val = (SqlObject)expression.GetArgument("static");
                string str = val.ToString();
                if (str.Equals("initially deferred"))
                    return true;
                if (str.Equals("initially immediate"))
                    return false;

                throw new ApplicationException("Unexpected initial check type '" + str + "'");
            }

            throw new ApplicationException("Expecting static expression");
        }
开发者ID:ikvm,项目名称:deveelsql,代码行数:15,代码来源:SqlInterpreter_DDL.cs


示例19: Count

        public static ITable Count(QueryProcessor processor, bool distinct, ITable group, Expression[] args)
        {
            // Only 1 argument allowed
            if (args.Length > 1)
                throw new ArgumentException("Only one argument permitted for COUNT function.");

            // If the parameter is a function operation with name "star" then this is
            // a simple group size result
            Expression arg = args[0];
            if (arg.Type == ExpressionType.Function &&
                arg.GetArgument("name").Equals("star")) {
                return QueryProcessor.ResultTable(SqlObject.CastTo(group.RowCount, SqlType.Numeric));
            }

            // Otherwise, if this is a distinct,
            if (distinct) {
                group = processor.DistinctSubset(group, args);
                // The above process removes null values so we return the count,
                return QueryProcessor.ResultTable(SqlObject.CastTo(group.RowCount, SqlType.Numeric));
            }

            // Otherwise, we need to iterate through a count all none null values,
            return ProcessAggregate(processor, false, group, args, new CountAggregateInspector());
        }
开发者ID:ikvm,项目名称:deveelsql,代码行数:24,代码来源:SystemFunctions_Aggregate.cs


示例20: ClearGraph

        public void ClearGraph(Expression expression)
        {
            // The graph should only have 'FETCHTABLE', 'JOIN', 'FILTER' and 'FUNCTION'
            // operations in the graph.  The FUNCTION expressions are themselves other
            // costed operation graphs.
            if (expression is FilterExpression) {
                // Recurse to the child
                ClearGraph(((FilterExpression)expression).Child);
            } else if (expression is JoinExpression) {
                JoinExpression joinExp = (JoinExpression) expression;
                // Recurse the left and right nodes
                ClearGraph(joinExp.Left);
                ClearGraph(joinExp.Right);
            } else if (expression is AliasTableNameExpression) {
            } else if (expression is FunctionExpression) {
                // This does not have costing information we should clear
                return;
            } else {
                throw new ApplicationException("Unknown operation type in graph.");
            }

            // Clear the costing information
            expression.UnsetCost();
        }
开发者ID:ikvm,项目名称:deveelsql,代码行数:24,代码来源:QueryCostModel.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Expressions.SqlExpression类代码示例发布时间:2022-05-24
下一篇:
C# Connection.DIConnection类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap