mirror of
https://github.com/bitwarden/server.git
synced 2026-02-05 00:23:24 +08:00
Split out repositories to Infrastructure.Dapper / EntityFramework (#1759)
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Bit.Core.Enums.Provider;
|
||||
using Bit.Core.Models.Data;
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.Repositories.Queries
|
||||
{
|
||||
public class UserReadPublicKeysByProviderUserIdsQuery : IQuery<ProviderUserPublicKey>
|
||||
{
|
||||
private readonly Guid _providerId;
|
||||
private readonly IEnumerable<Guid> _ids;
|
||||
|
||||
public UserReadPublicKeysByProviderUserIdsQuery(Guid providerId, IEnumerable<Guid> Ids)
|
||||
{
|
||||
_providerId = providerId;
|
||||
_ids = Ids;
|
||||
}
|
||||
|
||||
public virtual IQueryable<ProviderUserPublicKey> Run(DatabaseContext dbContext)
|
||||
{
|
||||
var query = from pu in dbContext.ProviderUsers
|
||||
join u in dbContext.Users
|
||||
on pu.UserId equals u.Id
|
||||
where _ids.Contains(pu.Id) &&
|
||||
pu.Status == ProviderUserStatusType.Accepted &&
|
||||
pu.ProviderId == _providerId
|
||||
select new { pu, u };
|
||||
return query.Select(x => new ProviderUserPublicKey
|
||||
{
|
||||
Id = x.pu.Id,
|
||||
PublicKey = x.u.PublicKey,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user