Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static bool IsTenantProvisioned(string tenantSchema, DbConnection connection)
- {
- // Execute plain SQL query to check for tenant schema existence
- using (SqlConnection sqlConnection = new SqlConnection(connection.ConnectionString))
- {
- using (SqlCommand cmd = new SqlCommand())
- {
- cmd.Connection = sqlConnection;
- cmd.CommandText = string.Format("SELECT COUNT(*) FROM sys.schemas WHERE name = '{0}'", tenantSchema);
- cmd.CommandType = CommandType.Text;
- try
- {
- sqlConnection.Open();
- int total = (int)cmd.ExecuteScalar();
- if (total > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- catch (SqlException e)
- {
- return false;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement