Пример #1
0
 /// <summary>
 /// Creates a table on a remote database server.
 /// </summary>
 /// <param name="adapter">Open adapter to a database.</param>
 /// <param name="schema">The schema of the table to create.</param>
 /// <returns>True if table is successfully created.</returns>
 public static bool CreateTable(IDbAdapter adapter, DataTable schema)
 {
     try
     {
         if (!adapter.ExistsTable(schema.TableName))
         {
             adapter.CreateTable(schema);
         }
         else
         {
             Log.Debug(String.Format("Database table '{0}' already exists; skipping creation.", schema.TableName));
         }
         return true;
     }
     catch (DbException ex)
     {
         Log.Error(String.Format("Failed to create database table '{0}': {1}", schema.TableName, ex.Message));
         return false;
     }
 }
Пример #2
0
 /// <summary>
 /// Creates a table on a remote database server and indexes the table.
 /// </summary>
 /// <param name="adapter">Open adapter to a database.</param>
 /// <param name="schema">The schema of the table to create.</param>
 /// <param name="indexes">A dictionary that contains the indexes to create and whether the indexes are clustered.</param>
 /// <returns>True if table is successfully created.</returns>
 public static bool CreateTable(IDbAdapter adapter, DataTable schema, IDictionary <string, bool> indexes)
 {
     try
     {
         if (!adapter.ExistsTable(schema.TableName))
         {
             adapter.CreateTable(schema);
             CreateIndexes(adapter, schema, indexes);
         }
         else
         {
             Log.Debug(String.Format("Database table '{0}' already exists; skipping creation.", schema.TableName));
         }
         return(true);
     }
     catch (DbException ex)
     {
         Log.Error(String.Format("Failed to create database table '{0}': {1}", schema.TableName, ex.Message));
         return(false);
     }
 }