fix cipher org details with collections task (#6342)

This commit is contained in:
Jordan Aasen 2025-09-16 09:00:32 -07:00 committed by GitHub
parent da48603c18
commit 6e309c6e04
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -902,13 +902,17 @@ public class CipherRepository : Repository<Cipher, Guid>, ICipherRepository
var dict = new Dictionary<Guid, CipherOrganizationDetailsWithCollections>(); var dict = new Dictionary<Guid, CipherOrganizationDetailsWithCollections>();
var tempCollections = new Dictionary<Guid, List<Guid>>(); var tempCollections = new Dictionary<Guid, List<Guid>>();
await connection.QueryAsync<CipherOrganizationDetailsWithCollections, CollectionCipher, CipherOrganizationDetailsWithCollections>( await connection.QueryAsync<
CipherOrganizationDetails,
CollectionCipher,
CipherOrganizationDetailsWithCollections
>(
$"[{Schema}].[CipherOrganizationDetails_ReadByOrganizationIdExcludingDefaultCollections]", $"[{Schema}].[CipherOrganizationDetails_ReadByOrganizationIdExcludingDefaultCollections]",
(cipher, cc) => (cipher, cc) =>
{ {
if (!dict.TryGetValue(cipher.Id, out var details)) if (!dict.TryGetValue(cipher.Id, out var details))
{ {
details = new CipherOrganizationDetailsWithCollections(cipher, /*dummy*/null); details = new CipherOrganizationDetailsWithCollections(cipher, new Dictionary<Guid, IGrouping<Guid, CollectionCipher>>());
dict.Add(cipher.Id, details); dict.Add(cipher.Id, details);
tempCollections[cipher.Id] = new List<Guid>(); tempCollections[cipher.Id] = new List<Guid>();
} }
@ -925,7 +929,6 @@ public class CipherRepository : Repository<Cipher, Guid>, ICipherRepository
commandType: CommandType.StoredProcedure commandType: CommandType.StoredProcedure
); );
// now assign each List<Guid> back to the array property in one shot
foreach (var kv in dict) foreach (var kv in dict)
{ {
kv.Value.CollectionIds = tempCollections[kv.Key].ToArray(); kv.Value.CollectionIds = tempCollections[kv.Key].ToArray();