internal RenameCommand(EFNormalizableItem element, string newName, bool uniquenessIsCaseSensitive) { Element = element; NewName = newName; UniquenessIsCaseSensitive = uniquenessIsCaseSensitive; OldName = Element.GetNameAttribute().Value; }
private bool ValidateName(out string errorMessage) { // Unlike C# and TSql refactoring, we won't allow the user to proceed with a rename that causes a name conflict (C# and TSql // give a warning and allow you to proceed). This is because our rename command will fail in the case of name conflicts, so // we need return a hard error in the rename dialog. EFAttribute attr = _objectToRename.GetNameAttribute(); errorMessage = null; AttributeContentValidator contentValidator = _objectToRename.Artifact.ModelManager.GetAttributeContentValidator(_objectToRename.Artifact); if (!contentValidator.IsValidAttributeValue(this.NewName, attr)) { // not valid content errorMessage = Microsoft.Data.Entity.Design.Resources.RefactorRename_InvalidName; return(false); } Property property = _objectToRename as Property; if (_objectToRename is EntityType) { if (!ModelHelper.IsUniqueNameForExistingItem(_objectToRename, this.NewName, true, out errorMessage)) { return(false); } } else if (property != null) { if (!ModelHelper.IsUniqueNameForExistingItem(property, this.NewName, true, out errorMessage)) { errorMessage = string.Format(CultureInfo.CurrentCulture, Microsoft.Data.Entity.Design.Model.Resources.NAME_NOT_UNIQUE, this.NewName); return(false); } } else if (_objectToRename is Association) { if (!ModelHelper.IsUniqueNameForExistingItem(_objectToRename, this.NewName, true, out errorMessage)) { return(false); } } return(true); }