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

C# IQueryContext类代码示例

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

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



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

示例1: ChildQueryContext

        public ChildQueryContext(IQueryContext parentContext)
        {
            if (parentContext == null)
                throw new ArgumentNullException("parentContext");

            this.parentContext = parentContext;
        }
开发者ID:furesoft,项目名称:deveeldb,代码行数:7,代码来源:ChildQueryContext.cs


示例2: Evaluate

 /// <inheritdoc/>
 public virtual ITable Evaluate(IQueryContext context)
 {
     // MILD HACK: Cast the context to a DatabaseQueryContext
     //DatabaseQueryContext dbContext = (DatabaseQueryContext)context;
     //return dbContext.Database.SingleRowTable;
     throw new NotImplementedException();
 }
开发者ID:kaktusan,项目名称:plsqlparser,代码行数:8,代码来源:SingleRowTableNode.cs


示例3: AddTestData

        private void AddTestData(IQueryContext context)
        {
            var table = context.GetMutableTable(ObjectName.Parse("APP.test_table"));
            var row = table.NewRow();
            row.SetValue("id", DataObject.Integer(0));
            row.SetValue("first_name", DataObject.String("John"));
            row.SetValue("last_name", DataObject.String("Doe"));
            row.SetValue("birth_date", DataObject.Date(new SqlDateTime(1977, 01, 01)));
            row.SetValue("active", DataObject.Boolean(false));
            table.AddRow(row);

            row = table.NewRow();
            row.SetValue("id", DataObject.Integer(1));
            row.SetValue("first_name", DataObject.String("Jane"));
            row.SetValue("last_name", DataObject.String("Doe"));
            row.SetValue("birth_date", DataObject.Date(new SqlDateTime(1978, 11, 01)));
            row.SetValue("active", DataObject.Boolean(true));
            table.AddRow(row);

            row = table.NewRow();
            row.SetValue("id", DataObject.Integer(2));
            row.SetValue("first_name", DataObject.String("Roger"));
            row.SetValue("last_name", DataObject.String("Rabbit"));
            row.SetValue("birth_date", DataObject.Date(new SqlDateTime(1985, 05, 05)));
            row.SetValue("active", DataObject.Boolean(true));
            table.AddRow(row);
        }
开发者ID:prepare,项目名称:deveeldb,代码行数:27,代码来源:UpdateStatementTests.cs


示例4: PrepareStatement

        protected override SqlPreparedStatement PrepareStatement(IExpressionPreparer preparer, IQueryContext context)
        {
            var tableName = context.ResolveTableName(TableName);
            if (!context.TableExists(tableName))
                throw new ObjectNotFoundException(tableName);

            var queryExpression = new SqlQueryExpression(new[]{SelectColumn.Glob("*") });
            queryExpression.FromClause.AddTable(tableName.FullName);
            queryExpression.WhereExpression = WherExpression;

            var queryFrom = QueryExpressionFrom.Create(context, queryExpression);
            var queryPlan = context.DatabaseContext().QueryPlanner().PlanQuery(context, queryExpression, null);

            var columns = new List<SqlAssignExpression>();
            foreach (var assignment in Assignments) {
                var columnName = ObjectName.Parse(assignment.ColumnName);

                var refName = queryFrom.ResolveReference(columnName);
                var expression = assignment.Expression.Prepare(queryFrom.ExpressionPreparer);

                var assign = SqlExpression.Assign(SqlExpression.Reference(refName), expression);
                columns.Add(assign);
            }

            return new Prepared(tableName, queryPlan, columns.ToArray(), Limit);
        }
开发者ID:prepare,项目名称:deveeldb,代码行数:26,代码来源:UpdateStatement.cs


示例5: ReturnTypeVisitor

        public ReturnTypeVisitor(IQueryContext queryContext, IVariableResolver variableResolver)
        {
            this.queryContext = queryContext;
            this.variableResolver = variableResolver;

            dataType = PrimitiveTypes.Null();
        }
开发者ID:prepare,项目名称:deveeldb,代码行数:7,代码来源:ReturnTypeVisitor.cs


示例6: Evaluate

        public override ITable Evaluate(IQueryContext context)
        {
            // Solve the left branch result
            ITable leftResult = Left.Evaluate(context);
            // Solve the right branch result
            ITable rightResult = Right.Evaluate(context);

            // If the rightExpression is a simple variable then we have the option
            // of optimizing this join by putting the smallest table on the LHS.
            ObjectName rhsVar = rightExpression.AsVariable();
            ObjectName lhsVar = leftVar;
            Operator op = joinOp;
            if (rhsVar != null) {
                // We should arrange the expression so the right table is the smallest
                // of the sides.
                // If the left result is less than the right result
                if (leftResult.RowCount < rightResult.RowCount) {
                    // Reverse the join
                    rightExpression = Expression.Variable(lhsVar);
                    lhsVar = rhsVar;
                    op = op.Reverse();
                    // Reverse the tables.
                    ITable t = rightResult;
                    rightResult = leftResult;
                    leftResult = t;
                }
            }

            // The join operation.
            return leftResult.SimpleJoin(context, rightResult, lhsVar, op, rightExpression);
        }
开发者ID:kaktusan,项目名称:plsqlparser,代码行数:31,代码来源:JoinNode.cs


示例7: Evaluate

        public override ITable Evaluate(IQueryContext context)
        {
            var leftResult = Left.Evaluate(context);
            var rightResult = Right.Evaluate(context);

            return leftResult.Union(rightResult);
        }
开发者ID:furesoft,项目名称:deveeldb,代码行数:7,代码来源:LogicalUnionNode.cs


示例8: CreateViews

        public static void CreateViews(IQueryContext context)
        {
            // This view shows the grants that the user has (no join, only priv_bit).
            context.ExecuteQuery("CREATE VIEW INFORMATION_SCHEMA.ThisUserSimpleGrant AS " +
                                 "  SELECT \"priv_bit\", \"object\", \"name\", \"user\", " +
                                 "         \"grant_option\", \"granter\" " +
                                 "    FROM " + SystemSchema.UserGrantsTableName +
                                 "   WHERE ( user = user() OR user = '@PUBLIC' )");

            // This view shows the grants that the user is allowed to see
            context.ExecuteQuery("CREATE VIEW INFORMATION_SCHEMA.ThisUserGrant AS " +
                                 "  SELECT \"description\", \"object\", \"name\", \"user\", " +
                                 "         \"grant_option\", \"granter\" " +
                                 "    FROM " + SystemSchema.UserGrantsTableName + ", " + SystemSchema.PrivilegesTableName +
                                 "   WHERE ( user = user() OR user = '@PUBLIC' )" +
                                 "     AND " + SystemSchema.UserGrantsTableName + ".priv_bit = " +
                                 SystemSchema.PrivilegesTableName + ".priv_bit");

            // A view that represents the list of schema this user is allowed to view
            // the contents of.
            context.ExecuteQuery("CREATE VIEW INFORMATION_SCHEMA.ThisUserSchemaInfo AS " +
                                 "  SELECT * FROM  " + SystemSchema.SchemaInfoTableName +
                                 "   WHERE \"name\" IN ( " +
                                 "     SELECT \"name\" " +
                                 "       FROM INFORMATION_SCHEMA.ThisUserGrant " +
                                 "      WHERE \"object\" = " + ((int)DbObjectType.Schema) +
                                 "        AND \"description\" = '" + Privileges.List + "' )");

            // A view that exposes the table_columns table but only for the tables
            // this user has read access to.
            context.ExecuteQuery("CREATE VIEW INFORMATION_SCHEMA.ThisUserTableColumns AS " +
                                 "  SELECT * FROM " + SystemSchema.TableColumnsTableName +
                                 "   WHERE \"schema\" IN ( " +
                                 "     SELECT \"name\" FROM INFORMATION_SCHEMA.ThisUserSchemaInfo )");

            // A view that exposes the 'table_info' table but only for the tables
            // this user has read access to.
            context.ExecuteQuery("CREATE VIEW INFORMATION_SCHEMA.ThisUserTableInfo AS " +
                                 "  SELECT * FROM " + SystemSchema.TableInfoTableName +
                                 "   WHERE \"schema\" IN ( " +
                                 "     SELECT \"name\" FROM INFORMATION_SCHEMA.ThisUserSchemaInfo )");

            context.ExecuteQuery("  CREATE VIEW " + Tables + " AS " +
                                 "  SELECT NULL AS \"TABLE_CATALOG\", \n" +
                                 "         \"schema\" AS \"TABLE_SCHEMA\", \n" +
                                 "         \"name\" AS \"TABLE_NAME\", \n" +
                                 "         \"type\" AS \"TABLE_TYPE\", \n" +
                                 "         \"other\" AS \"REMARKS\", \n" +
                                 "         NULL AS \"TYPE_CATALOG\", \n" +
                                 "         NULL AS \"TYPE_SCHEMA\", \n" +
                                 "         NULL AS \"TYPE_NAME\", \n" +
                                 "         NULL AS \"SELF_REFERENCING_COL_NAME\", \n" +
                                 "         NULL AS \"REF_GENERATION\" \n" +
                                 "    FROM INFORMATION_SCHEMA.ThisUserTableInfo \n");

            context.ExecuteQuery("  CREATE VIEW " + Schemata + " AS " +
                                 "  SELECT \"name\" AS \"TABLE_SCHEMA\", \n" +
                                 "         NULL AS \"TABLE_CATALOG\" \n" +
                                 "    FROM INFORMATION_SCHEMA.ThisUserSchemaInfo\n");
        }
开发者ID:furesoft,项目名称:deveeldb,代码行数:60,代码来源:InformationSchema.cs


示例9: Evaluate

        /// <inheritdoc/>
        public override ITable Evaluate(IQueryContext context)
        {
            var t = Child.Evaluate(context);

            var exp = Expression;

            // Assert that all variables in the expression are identical.
            var columnNames = exp.DiscoverReferences();
            ObjectName columnName = null;
            foreach (var cv in columnNames) {
                if (columnName != null && !cv.Equals(columnName))
                    throw new InvalidOperationException("Range plan does not contain common column.");

                columnName = cv;
            }

            // Find the variable field in the table.
            var col = t.IndexOfColumn(columnName);
            if (col == -1)
                throw new InvalidOperationException("Could not find column reference in table: " + columnName);

            var field = t.TableInfo[col];

            // Calculate the range
            var range = new IndexRangeSet();
            var calculator = new RangeSetCalculator(context, field, range);
            range = calculator.Calculate(exp);

            // Select the range from the table
            var ranges = range.ToArray();
            return t.SelectRange(columnName, ranges);
        }
开发者ID:prepare,项目名称:deveeldb,代码行数:33,代码来源:RangeSelectNode.cs


示例10: Evaluate

 public override ITable Evaluate(IQueryContext context)
 {
     ITable t = Child.Evaluate(context);
     // NOTE: currently this uses exhaustive select but should exploit
     //   function indexes when they are available.
     return t.ExhaustiveSelect(context, expression);
 }
开发者ID:kaktusan,项目名称:plsqlparser,代码行数:7,代码来源:FunctionalSelectNode.cs


示例11: Evaluate

        public ITable Evaluate(IQueryContext context)
        {
            IQueryPlanNode node = CreateChildNode(context);
            var t = node.Evaluate(context);

            return AliasName != null ? new ReferenceTable(t, AliasName) : t;
        }
开发者ID:furesoft,项目名称:deveeldb,代码行数:7,代码来源:FetchViewNode.cs


示例12: Evaluate

 public override ITable Evaluate(IQueryContext context)
 {
     // Solve the left branch result
     var leftResult = Left.Evaluate(context);
     // Solve the Join (natural)
     return leftResult.NaturalJoin(Right.Evaluate(context));
 }
开发者ID:furesoft,项目名称:deveeldb,代码行数:7,代码来源:NaturalJoinNode.cs


示例13: Evaluate

        public override ITable Evaluate(IQueryContext context)
        {
            // Evaluate the child
            ITable t = Child.Evaluate(context);

            var binary = (BinaryExpression) expression;

            // Perform the pattern search expression on the table.
            ObjectName lhsVar = binary.Left.AsVariable();
            if (lhsVar != null) {
                // LHS is a simple variable so do a simple select
                Operator op = binary.Operator;
                return t.SimpleSelect(context, lhsVar, op, binary.Right);
            }

            // LHS must be a constant so we can just evaluate the expression
            // and see if we get true, false, null, etc.
            DataObject v = expression.Evaluate(context);

            // If it evaluates to NULL or FALSE then return an empty set
            if (v.IsNull || v.Value.Equals(false))
                return t.EmptySelect();

            return t;
        }
开发者ID:kaktusan,项目名称:plsqlparser,代码行数:25,代码来源:SimplePatternSelectNode.cs


示例14: MatchesInvoke

        internal override bool MatchesInvoke(Invoke invoke, IQueryContext queryContext)
        {
            if (invoke == null)
                return false;

            bool ignoreCase = true;
            if (queryContext != null)
                ignoreCase = queryContext.IgnoreIdentifiersCase();

            if (!RoutineName.Equals(invoke.RoutineName, ignoreCase))
                return false;

            var inputParams = Parameters.Where(parameter => parameter.IsInput).ToList();
            if (invoke.Arguments.Length != inputParams.Count)
                return false;

            for (int i = 0; i < invoke.Arguments.Length; i++) {
                // TODO: support variable evaluation here? or evaluate parameters before reaching here?
                if (!invoke.Arguments[i].IsConstant())
                    return false;

                var argType = invoke.Arguments[i].ReturnType(queryContext, null);
                var paramType = Parameters[i].Type;

                // TODO: verify if this is assignable (castable) ...
                if (!paramType.IsComparable(argType))
                    return false;
            }

            return true;
        }
开发者ID:prepare,项目名称:deveeldb,代码行数:31,代码来源:ProcedureInfo.cs


示例15: updateVerseTable

        private void updateVerseTable(IQueryContext context, SqliteTransaction transaction)
        {
            var sql = SqlBuilder.Update("Verses")
                .Set(DbVerse.BookField + " = @Book",
                    DbVerse.BeginChapterField + " = @BeginChapter",
                    DbVerse.EndChapterField + " = @EndChapter",
                    DbVerse.BeginVerseField + " = @BeginVerse",
                    DbVerse.EndVerseField + " = @EndVerse",
                    DbVerse.BodyField + " = @Body",
                    DbVerse.TitleField + " = @Title",
                    DbVerse.DateField + " = @Date",
                    DbVerse.TranslationField + " = @Translation")
                .Where(DbVerse.VerseIdField + " = @VerseId");

            var sqlParams = new
            {
                Book = _verse.Reference.Book.Id,
                BeginChapter = _verse.Reference.From.Chapter,
                EndChapter = _verse.Reference.To.Chapter,
                BeginVerse = _verse.Reference.From.Verse,
                EndVerse = _verse.Reference.To.Verse,
                Body = _verse.Body,
                Title = _verse.Title,
                Date = _verse.Date,
                Translation = _verse.Translation.ToDatabaseEntity().Id,
                VerseId = _verse.VerseId
            };

            context.Connection.Execute(sql, transaction, sqlParams);
        }
开发者ID:pcrockett,项目名称:Ruminate,代码行数:30,代码来源:UpdateVerseCommand.cs


示例16: CursorManager

        public CursorManager(IQueryContext context)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            Context = context;
            cursors = new List<Cursor>();
        }
开发者ID:furesoft,项目名称:deveeldb,代码行数:8,代码来源:CursorManager.cs


示例17: PrepareStatement

        protected override SqlPreparedStatement PrepareStatement(IExpressionPreparer preparer, IQueryContext context)
        {
            if (String.IsNullOrEmpty(TableName))
                throw new StatementPrepareException("The table name is required.");

            var tableName = context.ResolveTableName(TableName);
            return new Prepared(tableName, Action);
        }
开发者ID:prepare,项目名称:deveeldb,代码行数:8,代码来源:AlterTableStatement.cs


示例18: Evaluate

        public override ITable Evaluate(IQueryContext context)
        {
            var leftResult = Left.Evaluate(context);
            var rightResult = Right.Evaluate(context);

            // Form the composite table
            return leftResult.Composite(rightResult, CompositeFunction, All);
        }
开发者ID:furesoft,项目名称:deveeldb,代码行数:8,代码来源:CompositeNode.cs


示例19: Evaluate

        public override ITable Evaluate(IQueryContext context)
        {
            // Solve the child branch result
            var table = Child.Evaluate(context);

            // The select operation.
            return table.SimpleSelect(context, ColumnName, OperatorType, Expression);
        }
开发者ID:prepare,项目名称:deveeldb,代码行数:8,代码来源:SimpleSelectNode.cs


示例20: CreateViews

 public static void CreateViews(IQueryContext context)
 {
     context.ExecuteCreateView("INFORMATION_SCHEMA.ThisUserSimpleGrant",
         "  SELECT \"priv_bit\", \"object\", \"param\", \"grantee\", " +
         "         \"grant_option\", \"granter\" " +
         "    FROM " + SystemSchema.UserGrantsTableName +
         "   WHERE ( grantee = user() OR grantee = '@PUBLIC' )");
 }
开发者ID:prepare,项目名称:deveeldb,代码行数:8,代码来源:InformationSchema.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# IQueryPlanNode类代码示例发布时间:2022-05-24
下一篇:
C# IQueryBuilder类代码示例发布时间: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