0
kkmy created
Hello,
I have a join query like this:
var result = await
(
from car in await _carRepository.GetQueryableAsync()
join iu in await _identityUserRepository.GetQueryableAsync() on car.CreatorId equals iu.Id
where car.Code == "CAR-1"
select new CarDto
{
Id = car.Id,
Code = car.Code,
CreatedAt = car.CreationTime,
CreatedBy = iu.Name
}
).FirstOrDefaultAsync();
However, this does not work since IdentityUserRepository
does not have a GetQueryableAsync()
method. What should be the approach here if I want to get the creator name in a join query?
Thanks.
3 Answer(s)
-
0
hi
Is your code in the AppService layer?
-
1
Hi,
IIdentityUserRepository
implementsIBasicRepository
that does not have GetQueryableAsync() method on it.If you need, you can use
IRepository<IdentityUser,Guid>
by injecting it.It has
GetQueryableAsync
method that you can use:public class MyService { protected readonly IRepository<IdentityUser, Guid> _userRepository; public MyService(IRepository<IdentityUser, Guid> userRepository) { _userRepository = userRepository; } public async Task DoSomethingAsync() { var queryable = await _userRepository.GetQueryableAsync(); // Do something with the users } }
-
0
This works, thank you so much.