internal static Dapper.SqlMapper.Identity GetIdentity(MockDbCommand mockDbCommand, IIdentityComparer identityComparer) { var identities = QueryCache.Keys .Cast <Dapper.SqlMapper.Identity>() .Where(id => identityComparer.Matches(mockDbCommand, id)) .ToArray(); if (identities.Length <= 1) { return(identities.SingleOrDefault() ?? SingleIdentityIfTextMatches(mockDbCommand, identityComparer) ?? throw GetIdentityNotFoundException(mockDbCommand)); } var ambiguous = identities.Select(id => $"`{id.type?.FullName ?? "<untyped>"}`") .OrderBy(id => id) .ToArray(); throw GetIdentityAmbiguousException(mockDbCommand, ambiguous); }
private static Dapper.SqlMapper.Identity SingleIdentityIfTextMatches(MockDbCommand mockDbCommand, IIdentityComparer identityComparer) { if (QueryCache.Keys.Count != 1) { return(null); } return(QueryCache.Keys .Cast <Dapper.SqlMapper.Identity>() .Where(id => identityComparer.TextMatches(mockDbCommand, id)) .SingleOrDefault()); }
public DefaultIdentityBatchMerge(IIdentityComparer <Contact> proximityComparer, IIdentityMerge <Contact> identityMerge) { _proximityComparer = proximityComparer; _identityMerge = identityMerge; }