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


C# IQuery.ExecuteQuery方法代码示例

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


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

示例1: CoreExecuteQuery

        protected IQueryResponse[] CoreExecuteQuery(IQuery context, string text, IEnumerable<QueryParameter> parameters, QueryParameterStyle parameterStyle)
        {
            // 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, parameterStyle);
            if (parameters != null) {
                foreach (var p in parameters) {
                    var c = p.SqlType.TypeCode;
                    switch (c) {
                        case SqlTypeCode.Blob:
                        case SqlTypeCode.Clob:
                        case SqlTypeCode.LongVarBinary:
                        case SqlTypeCode.LongVarChar:
                        case SqlTypeCode.VarBinary:
                            throw new NotImplementedException("TODO: Download the Large-Objects and replace with a reference");
                        default:
                            query.Parameters.Add(p);
                            break;
                    }
                }
            }

            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 {
                    if (result.Type == StatementResultType.Exception)
                        throw result.Error;

                    queryResult = new QueryResult(query, result, context.AutoCommit());
                    resultId = AddResult(queryResult);
                } catch (Exception) {
                    if (resultId != -1)
                        DisposeResult(resultId);

                    throw;
                }

                var taken = stopwatch.ElapsedMilliseconds;

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

                j++;
            }

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

示例2: CreateViews

        public static void CreateViews(IQuery query)
        {
            // This view shows the grants that the user has (no join, only priv_bit).
            query.ExecuteQuery("CREATE VIEW " + ThisUserSimpleGrantViewName + " 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
            query.ExecuteQuery("CREATE VIEW " + ThisUserGrantViewName + " 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.
            query.ExecuteQuery("CREATE VIEW " + ThisUserSchemaInfoViewName + " AS " +
                                 "  SELECT * FROM  " + SystemSchema.SchemaInfoTableName +
                                 "   WHERE \"name\" IN ( " +
                                 "     SELECT \"name\" " +
                                 "       FROM " + ThisUserGrantViewName + " " +
                                 "      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.
            query.ExecuteQuery("CREATE VIEW " + ThisUserTableColumnsViewName + " AS " +
                                 "  SELECT * FROM " + SystemSchema.TableColumnsTableName +
                                 "   WHERE \"schema\" IN ( " +
                                 "     SELECT \"name\" FROM " + ThisUserSchemaInfoViewName + ")");

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

            query.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 " + ThisUserTableInfoViewName + "\n");

            query.ExecuteQuery("  CREATE VIEW " + Schemata + " AS " +
                                 "  SELECT \"name\" AS \"TABLE_SCHEMA\", \n" +
                                 "         NULL AS \"TABLE_CATALOG\" \n" +
                                 "    FROM " + ThisUserSchemaInfoViewName + "\n");

            query.ExecuteQuery("  CREATE VIEW " + Catalogs + " AS " +
                                 "  SELECT NULL AS \"TABLE_CATALOG\" \n" +
                                 "    FROM " + SystemSchema.SchemaInfoTableName + "\n" + // Hacky, this will generate a 0 row
                                 "   WHERE FALSE\n");

            query.ExecuteQuery("  CREATE VIEW " + Columns + " AS " +
                                 "  SELECT NULL AS \"TABLE_CATALOG\",\n" +
                                 "         \"schema\" AS \"TABLE_SCHEMA\",\n" +
                                 "         \"table\" AS \"TABLE_NAME\",\n" +
                                 "         \"column\" AS \"COLUMN_NAME\",\n" +
                                 "         \"sql_type\" AS \"DATA_TYPE\",\n" +
                                 "         \"type_desc\" AS \"TYPE_NAME\",\n" +
                                 "         IIF(\"size\" = -1, 1024, \"size\") AS \"COLUMN_SIZE\",\n" +
                                 "         NULL AS \"BUFFER_LENGTH\",\n" +
                                 "         \"scale\" AS \"DECIMAL_DIGITS\",\n" +
                                 "         IIF(\"sql_type\" = -7, 2, 10) AS \"NUM_PREC_RADIX\",\n" +
                                 "         IIF(\"not_null\", 0, 1) AS \"NULLABLE\",\n" +
                                 "         '' AS \"REMARKS\",\n" +
                                 "         \"default\" AS \"COLUMN_DEFAULT\",\n" +
                                 "         NULL AS \"SQL_DATA_TYPE\",\n" +
                                 "         NULL AS \"SQL_DATETIME_SUB\",\n" +
                                 "         IIF(\"size\" = -1, 1024, \"size\") AS \"CHAR_OCTET_LENGTH\",\n" +
                                 "         \"seq_no\" + 1 AS \"ORDINAL_POSITION\",\n" +
                                 "         IIF(\"not_null\", 'NO', 'YES') AS \"IS_NULLABLE\"\n" +
                                 "    FROM " + ThisUserTableColumnsViewName + "\n");

            query.ExecuteQuery("  CREATE VIEW " + ColumnPrivileges + " AS " +
                                 "  SELECT \"TABLE_CATALOG\",\n" +
                                 "         \"TABLE_SCHEMA\",\n" +
                                 "         \"TABLE_NAME\",\n" +
                                 "         \"COLUMN_NAME\",\n" +
                                 "         IIF(\"ThisUserGrant.granter\" = '@SYSTEM', \n" +
                                 "                        NULL, \"ThisUserGrant.granter\") AS \"GRANTOR\",\n" +
                                 "         IIF(\"ThisUserGrant.user\" = '@PUBLIC', \n" +
                                 "                    'public', \"ThisUserGrant.user\") AS \"GRANTEE\",\n" +
                                 "         \"ThisUserGrant.description\" AS \"PRIVILEGE\",\n" +
                                 "         IIF(\"grant_option\" = 'true', 'YES', 'NO') AS \"IS_GRANTABLE\" \n" +
                                 "    FROM " + Columns + ", INFORMATION_SCHEMA.ThisUserGrant \n" +
                                 "   WHERE CONCAT(columns.TABLE_SCHEMA, '.', columns.TABLE_NAME) = \n" +
                                 "         ThisUserGrant.name \n" +
//.........这里部分代码省略.........
开发者ID:ArsenShnurkov,项目名称:deveeldb,代码行数:101,代码来源:InformationSchema.cs

示例3: CoreExecuteQuery

        protected IQueryResponse[] CoreExecuteQuery(IQuery 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) {
                    if (resultId != -1)
                        DisposeResult(resultId);

                    throw;
                }

                var taken = stopwatch.ElapsedMilliseconds;

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

                j++;
            }

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


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