Galen.Ci.EntityFramework.DeploymentHistory.GetIsDeploymentHistoryTableExists C# (CSharp) Method

GetIsDeploymentHistoryTableExists() private static method

private static GetIsDeploymentHistoryTableExists ( DbConnection connection, string schemaName ) : bool
connection System.Data.Common.DbConnection
schemaName string
return bool
        private static bool GetIsDeploymentHistoryTableExists(DbConnection connection, string schemaName)
        {
            const string sql =
                "SELECT 1 " +
                "FROM INFORMATION_SCHEMA.TABLES " +
                "WHERE TABLE_SCHEMA = @SchemaName " +
                "AND TABLE_NAME = '__DeploymentHistory' ";

            DbCommand command = null;
            try
            {
                command = connection.CreateCommand();
                command.CommandText = sql;

                var schemaNameParam = command.CreateParameter();
                schemaNameParam.DbType = DbType.String;
                schemaNameParam.Direction = ParameterDirection.Input;
                schemaNameParam.ParameterName = "@SchemaName";
                schemaNameParam.Value = schemaName;
                command.Parameters.Add(schemaNameParam);

                var result = (int?)command.ExecuteScalar();

                return (result == 1);
            }
            finally
            {
                command.SafeDispose();
            }
        }