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


C# IQueryContext.ExecuteQuery方法代码示例

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


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

示例1: 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

示例2: CoreExecuteQuery

        protected IQueryResponse[] CoreExecuteQuery(IQueryContext context, string text, IEnumerable<QueryParameter> parameters)
        {
            // Where Query result eventually resides.
            int resultId = -1;

            // For each StreamableObject in the query object, translate it to a
            // IRef object that presumably has been pre-pushed onto the server from
            // the client.

            // Evaluate the sql Query.
            var query = new SqlQuery(text);
            if (parameters != null) {
                // TODO: Download the Large-Objects and replace with a reference
            }

            var stopwatch = new Stopwatch();
            stopwatch.Start();

            var results = context.ExecuteQuery(query);
            var responses = new IQueryResponse[results.Length];
            int j = 0;

            foreach (var result in results) {
                QueryResult queryResult;
                try {
                    queryResult = new QueryResult(query, result);
                    resultId = AddResult(queryResult);
                } catch (Exception e) {
                    if (resultId != -1)
                        DisposeResult(resultId);

                    throw;
                }

                var taken = stopwatch.Elapsed;

                // Return the Query response
                responses[j] = new QueryResponse(resultId, queryResult, (int)taken.TotalMilliseconds, "");

                j++;
            }

            stopwatch.Stop();
            return responses;
        }
开发者ID:prepare,项目名称:deveeldb,代码行数:45,代码来源:ServerConnector.cs


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