We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 15bf5c7 + 022b5bc commit 0d73858Copy full SHA for 0d73858
Orm/Xtensive.Orm/Sql/Model/NodeCollection.cs
@@ -39,13 +39,8 @@ public override void Add(TNode item)
39
{
40
base.Add(item);
41
var name = item.GetNameInternal();
42
- if (!string.IsNullOrEmpty(name)) {
43
- try {
44
- nameIndex.Add(name, item);
45
- }
46
- catch(ArgumentException) {
47
- throw new ArgumentException(string.Format(Strings.ExItemWithNameXAlreadyExists, name));
48
+ if (!string.IsNullOrEmpty(name) && !nameIndex.TryAdd(name, item)) {
+ throw new ArgumentException(string.Format(Strings.ExItemWithNameXAlreadyExists, name));
49
}
50
51
0 commit comments