diff --git a/ChangeLog/6.0.13_dev.txt b/ChangeLog/6.0.13_dev.txt index d2d9482215..a1a88f9563 100644 --- a/ChangeLog/6.0.13_dev.txt +++ b/ChangeLog/6.0.13_dev.txt @@ -4,4 +4,5 @@ [main] Join/LeftJoin is denied to have the same expression instance for both inner/outer selector [main] Addressed issue when wrong type of join was chosen when .First/FirstOrDefalult() method was used as subquery [main] Added dedicated exception when RenameFieldHint.TargetType exists in current model but absent in storage model +[main] Xtensive.Sql.Model.NodeCollection.Add() throws understandable exception in case of duplicate name of item [postgresql] Fixed issue of incorrect translation of contitional expressions including comparison with nullable fields \ No newline at end of file diff --git a/Orm/Xtensive.Orm/Sql/Model/NodeCollection.cs b/Orm/Xtensive.Orm/Sql/Model/NodeCollection.cs index 093774af4e..aadb24e4e0 100644 --- a/Orm/Xtensive.Orm/Sql/Model/NodeCollection.cs +++ b/Orm/Xtensive.Orm/Sql/Model/NodeCollection.cs @@ -30,12 +30,23 @@ public class NodeCollection: CollectionBaseSlim /// if this instance is read-only; otherwise, . public override bool IsReadOnly { get { return IsLocked || base.IsReadOnly; } } - /// + /// + /// Adds item to collection. + /// + /// Item to add + /// The item with same name already exists in the collection public override void Add(TNode item) { base.Add(item); - if (!string.IsNullOrEmpty(item.GetNameInternal())) - nameIndex.Add(item.GetNameInternal(), item); + var name = item.GetNameInternal(); + if (!string.IsNullOrEmpty(name)) { + try { + nameIndex.Add(name, item); + } + catch(ArgumentException) { + throw new ArgumentException(string.Format(Strings.ExItemWithNameXAlreadyExists, name)); + } + } } public override bool Remove(TNode item)