Пример #1
0
 protected override IDbCommand GetCreateTableCommand(IDbConnection connection, DataTable table)
 {
     return(CreateDbCommand(
                connection,
                $"if OBJECT_ID('{table.TableName}') is null \r\n" +
                "begin \r\n" +
                $"create {TableDefinitionGenerator.GetTableDefinition(table)}; \r\n" +
                "end"
                ));
 }
Пример #2
0
        protected override IDbCommand GetCreateTableCommand(IDbConnection connection, DataTable table)
        {
            var functionId = $"{Guid.NewGuid():N}";

            return(CreateDbCommand(
                       connection,
                       "start transaction;\r\n" +
                       $"create or replace function create_{functionId} ()\r\n" +
                       "returns void as\r\n" +
                       "$func$\r\n" +
                       "begin\r\n" +
                       $"if (select to_regclass('{table.TableName}') is null) then\r\n" +
                       $"create {TableDefinitionGenerator.GetTableDefinition(table)};\r\n" +
                       "end if;\r\n" +
                       "end\r\n" +
                       "$func$ language plpgsql;\r\n" +
                       $"select  create_{functionId} ();\r\n" +
                       $"drop function create_{functionId};\r\n" +
                       "commit transaction;"
                       ));
        }