protected override void ExecuteStatement(ExecutionContext context)
{
//if (!context.User.CanDrop(DbObjectType.View, ViewName))
// throw new MissingPrivilegesException(context.Request.UserName(), ViewName, Privileges.Drop);
// If the 'only if exists' flag is false, we need to check tables to drop
// exist first.
if (!IfExists) {
// If view doesn't exist, throw an error
if (!context.Request.Access().ViewExists(ViewName)) {
throw new ObjectNotFoundException(ViewName,
String.Format("The view '{0}' does not exist and cannot be dropped.", ViewName));
}
}
// Does the table already exist?
if (context.Request.Access().ViewExists(ViewName)) {
// Drop table in the transaction
context.Request.Access().DropObject(DbObjectType.View, ViewName);
// Revoke all the grants on the table
context.Request.Access().RevokeAllGrantsOnView(ViewName);
}
}