public override string ValidateQuery() { // Check if the table is used as a reference in any other table if (TableUtils.IsTableReferenced(DBName, TableName)) { // Table references exist => error message return(Responses.DROP_TABLE_REFERENCED); } return(Commands.MapCommandToSuccessResponse(QueryCommand)); }
public override string ValidateQuery() { if (TableUtils.IsTableReferenced(DatabaseName, TableName)) { var MongoDB = new MongoDBAcess(DatabaseName); ForeignKeyFiles = TableUtils.GetForeignKeyFiles(DatabaseName, TableName); foreach (var foreignKey in ForeignKeyFiles) { if (MongoDB.CollectionContainsKey(foreignKey, RemovedKey)) { // PK of the record is used as a FK in another table => error var tableName = foreignKey.Split('_'); return(Responses.DELETE_RECORD_USED_AS_FK + tableName[1]); } } } return(Responses.DELETE_RECORD_SUCCESS); }