Skip to content

Commit 7083ad7

Browse files
committed
Add support for custom comparer for NodeCollection and set altertative comparer for oracle
Oracle RDBMS supports case-sensitive schemas so schemas collection has to support case-sensitive name index.
1 parent f537b84 commit 7083ad7

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

Orm/Xtensive.Orm/Sql/Model/Catalog.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,20 @@ internal string GetActualDbName(IDictionary<string, string> catalogNameMap)
198198

199199
// Constructors
200200

201-
public Catalog(string name) : base(name)
201+
public Catalog(string name)
202+
: base(name)
202203
{
203204
schemas =
204205
new PairedNodeCollection<Catalog, Schema>(this, "Schemas", 1);
205206
}
207+
208+
public Catalog(string name, bool caseSensitiveNames = false)
209+
: base(name)
210+
{
211+
schemas = caseSensitiveNames
212+
? new PairedNodeCollection<Catalog, Schema>(this, "Schemas", 1, StringComparer.Ordinal)
213+
: new PairedNodeCollection<Catalog, Schema>(this, "Schemas", 1, StringComparer.OrdinalIgnoreCase);
214+
}
215+
206216
}
207217
}

Orm/Xtensive.Orm/Sql/Model/NodeCollection.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,16 @@ public NodeCollection(int capacity)
8484
{
8585
nameIndex = new Dictionary<string, TNode>(capacity, Comparer);
8686
}
87+
88+
/// <summary>
89+
/// Initializes new instance of this type.
90+
/// </summary>
91+
/// <param name="capacity">The initial collection capacity.</param>
92+
/// <param name="comparer">Comparer for inner name index.</param>
93+
public NodeCollection(int capacity, IEqualityComparer<string> comparer)
94+
: base(capacity)
95+
{
96+
nameIndex = new Dictionary<string, TNode>(capacity, comparer);
97+
}
8798
}
8899
}

Orm/Xtensive.Orm/Sql/Model/PairedNodeCollection.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
using System;
66
using System.Collections;
7+
using System.Collections.Generic;
78
using Xtensive.Core;
89

910
namespace Xtensive.Sql.Model
@@ -73,6 +74,24 @@ public PairedNodeCollection(TOwner owner, string property, int capacity)
7374
this.property = property;
7475
}
7576

77+
/// <summary>
78+
/// Initializes a new instance of the <see cref="PairedNodeCollection{TOwner,TNode}"/> class.
79+
/// </summary>
80+
/// <param name="owner">The collection owner.</param>
81+
/// <param name="property">Owner collection property.</param>
82+
/// <param name="capacity">The initial collection capacity.</param>
83+
/// <param name="equalityComparer">Comparer for inner name index.</param>
84+
public PairedNodeCollection(TOwner owner, string property, int capacity, IEqualityComparer<string> equalityComparer)
85+
: base(capacity, equalityComparer)
86+
{
87+
ArgumentValidator.EnsureArgumentNotNull(owner, nameof(owner));
88+
ArgumentValidator.EnsureArgumentNotNullOrEmpty(property, nameof(property));
89+
ArgumentValidator.EnsureArgumentNotNull(equalityComparer, nameof(equalityComparer));
90+
91+
this.owner = owner;
92+
this.property = property;
93+
}
94+
7695
#endregion
7796
}
7897
}

0 commit comments

Comments
 (0)