Beispiel #1
0
 private bool CheckDuplicatePK(string key)
 {
     try
     {
         return(MongoDB.CollectionContainsKey(TableName, key));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
        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);
        }