コード例 #1
0
        public override object VisitCreateTable([NotNull] PostgresParser.CreateTableContext context)
        {
            var res = new CreateTableQuery();

            res.TableName         = (TableRef)Visit(context.tableName());
            res.ColumnDefinitions = (List <ColumnDefinition>)Visit(context.createDefinitions());
            return(res);
        }
コード例 #2
0
 public async Task <IActionResult> CreateTableAsync(CreateTableQuery query)
 {
     try
     {
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #3
0
 internal void CreateTable(string tableName)
 {
     if (CreateTableQuery.GetAllQueryList().TryGetValue(tableName, out string val))
     {
         ExecuteQuerys(val);
     }
     else
     {
         throw new KeyNotFoundException();
     }
 }
コード例 #4
0
        public async Task <IActionResult> CreateTableAsync(CreateTableQuery query)
        {
            try
            {
                await tableService.CreateTableAsync(query.TableName);

                return(Ok(new { Res = true }));
            }
            catch (Exception e)
            {
                return(BadRequest(new { Res = false, Error = e.Message }));
            }
        }
コード例 #5
0
ファイル: IntegrationTests.cs プロジェクト: gmantaos/Quermine
        public async Task CreateTable(DbClient client)
        {
            await client.DropTableIfExists("people");

            CreateTableQuery query = client.GetQueryProvider().CreateTable("people");

            query.Field <int>("id", fieldProperties: FieldProperties.PrimaryKey | FieldProperties.AutoIncrement)
            .Field <string>("name")
            .Field <DateTime>("birthday");

            NonQueryResult res = await client.ExecuteNonQuery(query);

            client.Dispose();
        }
コード例 #6
0
        public override string CreateTableQuery(CreateTableQuery query)
        {
            StringBuilder str = new StringBuilder();

            str.AppendFormat("CREATE TABLE \"{0}\" (\n", query.tableName);

            StringBuilder fields = new StringBuilder();

            foreach (TableField field in query.fields)
            {
                if (fields.Length > 0)
                {
                    fields.AppendLine(",");
                }

                fields.AppendFormat("\t{0}", TableField(field, true));
            }

            str.Append(fields)
            .Append("\n);");

            return(str.ToString());
        }
コード例 #7
0
        public static string ExecuteCommand(string command)
        {
            var commandSplit      = command.Split(';');
            var executionResponse = "";

            switch (commandSplit[0])
            {
            case Commands.GET_ALL_DATABASES:
            {
                executionResponse = FetchDatabases();
            }
            break;

            case Commands.CREATE_DATABASE:
            {
                executionResponse = new CreateDatabaseQuery(commandSplit[1]).Execute();
            }
            break;

            case Commands.DROP_DATABASE:
            {
                executionResponse = new DropDatabaseQuery(commandSplit[1]).Execute();
            }
            break;

            case Commands.CREATE_TABLE:
            {
                executionResponse = new CreateTableQuery(commandSplit[1]).Execute();
            }
            break;

            case Commands.DROP_TABLE:
            {
                executionResponse = new DropTableQuery(commandSplit[1], commandSplit[2]).Execute();
            }
            break;

            case Commands.GET_ALL_TABLES:
            {
                executionResponse = FetchTables(commandSplit[1]);
            }
            break;

            case Commands.CREATE_INDEX:
            {
                executionResponse = FetchColumns(commandSplit[1], commandSplit[2]);
            }
            break;

            case Commands.CREATE_NONUNIQUE_INDEX:
            {
                executionResponse = new CreateIndexQuery(commandSplit[0], false, commandSplit[1], commandSplit[2], commandSplit[3], commandSplit[4]).Execute();
            }
            break;

            case Commands.CREATE_UNIQUE_INDEX:
            {
                executionResponse = new CreateIndexQuery(commandSplit[0], true, commandSplit[1], commandSplit[2], commandSplit[3], commandSplit[4]).Execute();
            }
            break;

            case Commands.GET_TABLE_INFORMATION:
            {
                executionResponse = FetchTableStructureInformation(commandSplit[1], commandSplit[2]);
            }
            break;

            case Commands.GET_TABLE_FOREIGN_KEYS:
            {
                executionResponse = FetchTableForeignKeys(commandSplit[1], commandSplit[2]);
            }
            break;

            case Commands.GET_TABLE_COLUMNS:
            {
                executionResponse = FetchTableColumns(commandSplit[1], commandSplit[2]);
            }
            break;

            case Commands.INSERT_INTO_TABLE:
            {
                executionResponse = new InsertQuery(commandSplit[1], commandSplit[2], commandSplit[3]).Execute();
            }
            break;

            case Commands.SELECT_RECORDS:
            {
                executionResponse = new SelectQuery(commandSplit[1], commandSplit[2]).Execute();
            }
            break;

            case Commands.SELECT_RECORDS_WITH_JOIN:
            {
                executionResponse = new SelectWithJoinQuery(commandSplit[1], commandSplit[2]).Execute();
            }
            break;

            case Commands.DELETE_RECORD:
            {
                executionResponse = new DeleteRowsQuery(commandSplit[1], commandSplit[2], commandSplit[3]).Execute();
            }
            break;
            }
            return(executionResponse);
        }