1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-01 08:02:49 -05:00

[PM-1191] fix: use join instead of select-subquery

EF6 is currently not able to translate LINQ that include selects after groupby statements. Using join let's us bypass this issue.
This commit is contained in:
Andreas Coroiu
2023-03-03 14:20:02 +01:00
parent 27adaf59b4
commit 353d7fa0e2

View File

@ -186,13 +186,13 @@ public class CollectionRepository : Repository<Core.Entities.Collection, Collect
{
var dbContext = GetDatabaseContext(scope);
var groups =
from cg in dbContext.CollectionGroups
where cg.Collection.OrganizationId == organizationId
from c in collections
join cg in dbContext.CollectionGroups on c.Id equals cg.CollectionId
group cg by cg.CollectionId into g
select g;
var users =
from cu in dbContext.CollectionUsers
where cu.Collection.OrganizationId == organizationId
from c in collections
join cu in dbContext.CollectionUsers on c.Id equals cu.CollectionId
group cu by cu.CollectionId into u
select u;
@ -230,19 +230,16 @@ public class CollectionRepository : Repository<Core.Entities.Collection, Collect
{
var dbContext = GetDatabaseContext(scope);
var groups =
from cg in dbContext.CollectionGroups
where cg.Collection.OrganizationId == organizationId
&& collections.Select(c => c.Id).Contains(cg.Collection.Id)
from c in collections
join cg in dbContext.CollectionGroups on c.Id equals cg.CollectionId
group cg by cg.CollectionId into g
select g;
var users =
from cu in dbContext.CollectionUsers
where cu.Collection.OrganizationId == organizationId
&& collections.Select(c => c.Id).Contains(cu.Collection.Id)
from c in collections
join cu in dbContext.CollectionUsers on c.Id equals cu.CollectionId
group cu by cu.CollectionId into u
select u;
return collections.Select(collection =>
new Tuple<Core.Entities.Collection, CollectionAccessDetails>(
collection,