mirror of
https://github.com/bitwarden/server.git
synced 2026-02-01 22:53:12 +08:00
33 lines
1.1 KiB
C#
33 lines
1.1 KiB
C#
|
|
using Bit.Core.Models.Data;
|
|||
|
|
|
|||
|
|
namespace Bit.Infrastructure.EntityFramework.Repositories.Queries;
|
|||
|
|
|
|||
|
|
public class ProviderOrganizationReadByUserIdQuery : IQuery<ProviderOrganizationProviderDetails>
|
|||
|
|
{
|
|||
|
|
private readonly Guid _userId;
|
|||
|
|
|
|||
|
|
public ProviderOrganizationReadByUserIdQuery(Guid userId)
|
|||
|
|
{
|
|||
|
|
_userId = userId;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public IQueryable<ProviderOrganizationProviderDetails> Run(DatabaseContext dbContext)
|
|||
|
|
{
|
|||
|
|
var query = from po in dbContext.ProviderOrganizations
|
|||
|
|
join ou in dbContext.OrganizationUsers
|
|||
|
|
on po.OrganizationId equals ou.OrganizationId
|
|||
|
|
join p in dbContext.Providers
|
|||
|
|
on po.ProviderId equals p.Id
|
|||
|
|
where ou.UserId == _userId
|
|||
|
|
select new ProviderOrganizationProviderDetails
|
|||
|
|
{
|
|||
|
|
Id = po.Id,
|
|||
|
|
OrganizationId = po.OrganizationId,
|
|||
|
|
ProviderId = po.ProviderId,
|
|||
|
|
ProviderName = p.Name,
|
|||
|
|
ProviderType = p.Type
|
|||
|
|
};
|
|||
|
|
return query;
|
|||
|
|
}
|
|||
|
|
}
|