Class Uniquifier
- Namespace
- Microsoft.EntityFrameworkCore.Infrastructure
- Assembly
- Microsoft.EntityFrameworkCore.dll
Provides methods for manipulating string identifiers.
public static class Uniquifier
- Inheritance
-
Uniquifier
- Inherited Members
Remarks
See Implementation of database providers and extensions for more information and examples.
Methods
Truncate(string, int, int?)
Ensures the given identifier is shorter than the given length by removing the extra characters from the end.
public static string Truncate(string identifier, int maxLength, int? uniquifier = null)
Parameters
identifier
stringThe identifier to shorten.
maxLength
intThe maximum length of the identifier.
uniquifier
int?An optional number that will be appended to the identifier.
Returns
- string
The shortened identifier.
Uniquify<T>(string, IReadOnlyDictionary<string, T>, int)
Creates a unique identifier by appending a number to the given string.
public static string Uniquify<T>(string currentIdentifier, IReadOnlyDictionary<string, T> otherIdentifiers, int maxLength)
Parameters
currentIdentifier
stringThe base identifier.
otherIdentifiers
IReadOnlyDictionary<string, T>A dictionary where the identifier will be used as a key.
maxLength
intThe maximum length of the identifier.
Returns
- string
A unique identifier.
Type Parameters
T
The type of the object the identifier maps to.
Uniquify<TKey, TValue>(string, IReadOnlyDictionary<TKey, TValue>, Func<string, TKey>, int)
Creates a unique identifier by appending a number to the given string.
public static string Uniquify<TKey, TValue>(string currentIdentifier, IReadOnlyDictionary<TKey, TValue> otherIdentifiers, Func<string, TKey> keySelector, int maxLength)
Parameters
currentIdentifier
stringThe base identifier.
otherIdentifiers
IReadOnlyDictionary<TKey, TValue>A dictionary where the identifier will be used as part of the key.
keySelector
Func<string, TKey>Creates the key object from an identifier.
maxLength
intThe maximum length of the identifier.
Returns
- string
A unique identifier.
Type Parameters
TKey
The type of the key that contains the identifier.
TValue
The type of the object the identifier maps to.