Class CompositeKey
- Namespace
- Excalibur.Data.IdentityMap
- Assembly
- Excalibur.Data.IdentityMap.dll
Builds deterministic composite keys for identity map lookups where a single external identifier is insufficient to uniquely identify an aggregate.
public static class CompositeKey
- Inheritance
-
CompositeKey
- Inherited Members
Examples
// Simple two-part key
var key = CompositeKey.Create("ClientNo", clientNo, "AccountNo", accountNo);
var accountId = await identityMap.ResolveAsync<Guid>("LegacyCore", key, "Account", ct);
// Three-part key
var key = CompositeKey.Create("Branch", branchCode, "Dept", deptCode, "EmpId", empId);
Remarks
Use this when the external system identifies records by a combination of fields
(e.g., ClientNo + AccountNo, BranchCode + EmployeeId). The resulting key is
a pipe-delimited, ordered string that is safe for use as the externalId
parameter in IIdentityMapStore operations.
Names are normalized to uppercase and trimmed. Values are trimmed and have pipe
characters escaped to prevent ambiguity. Names must not contain the pipe (|)
or equals (=) characters to avoid corrupting the serialized key format.
Methods
Create(params ReadOnlySpan<(string Name, string Value)>)
Creates a composite key from an arbitrary number of named parts.
public static string Create(params ReadOnlySpan<(string Name, string Value)> parts)
Parameters
partsReadOnlySpan<(string Name, string Value)>The key-value parts that form the composite key.
Returns
- string
A deterministic composite key string.
Exceptions
- ArgumentException
Thrown when
partsis empty, contains null/whitespace names or values, or any name contains the pipe (|) or equals (=) character.
Create(string, string, string, string)
Creates a composite key from two named parts.
public static string Create(string name1, string value1, string name2, string value2)
Parameters
name1stringThe first part name.
value1stringThe first part value.
name2stringThe second part name.
value2stringThe second part value.
Returns
- string
A deterministic composite key string.
Exceptions
- ArgumentException
Thrown when any name contains the pipe (
|) or equals (=) character.
Create(string, string, string, string, string, string)
Creates a composite key from three named parts.
public static string Create(string name1, string value1, string name2, string value2, string name3, string value3)
Parameters
name1stringThe first part name.
value1stringThe first part value.
name2stringThe second part name.
value2stringThe second part value.
name3stringThe third part name.
value3stringThe third part value.
Returns
- string
A deterministic composite key string.
Exceptions
- ArgumentException
Thrown when any name contains the pipe (
|) or equals (=) character.