internal static void SafeDropTable(this IDbConnection connection, string tableName) { var dbInspector = new SqlServerInspector(connection); var tableNames = dbInspector.GetTableNames(); if (tableNames.Contains(tableName, StringComparer.InvariantCultureIgnoreCase)) { var command = connection.CreateCommand(); command.CommandText = $"DROP TABLE {tableName}"; command.ExecuteNonQuery(); } }
public static DbInspector GetInstance(SqlConnectionStringBuilder sqlbuilder) { DbInspector retval = null; string connType = sqlbuilder.GetType().FullName; switch (connType) { case "System.Data.SqlClient.SqlConnectionStringBuilder": retval = new SqlServerInspector(sqlbuilder); break; default: retval = null; break; } return(retval); }