mirror of
https://github.com/bitwarden/server.git
synced 2024-11-25 12:45:18 +01:00
[PM-1191] collections cannot be managed in family organization (#2765)
* [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.
* [PM-1191] chore: simplify queries
* Revert "[PM-1191] chore: simplify queries"
This reverts commit f57443d8c4
.
This commit is contained in:
parent
5e3f4c9bbe
commit
2c9df6d1ff
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user