How to use linq in Repository?
public async Task<List<AdminUserDto> GetAsync(Guid id)
{
var data = from a in _adminRep
join b in _unitRep
on a.UnitId equals b.Id
select new AdminUserDto
{
Id = a.Id,
_sex = Sex.female,
DepartmentId = a.DepartmentId,
UnitId = a.UnitId,
UnitName = b.Name
};
return await data.ToListAsync();
}

Any other best-practices for multi-aggregateroot query
Please read document first. https://docs.abp.io/en/abp/latest/Entity-Framework-Core
Please read document first. https://docs.abp.io/en/abp/latest/Entity-Framework-Core
sorry,I've read it, but I could't find the ritght solution.
so you suggestion is that reference to the Volo.Abp.EntityFrameworkCore package in application?
https://github.com/abpframework/abp/blob/dev/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityRoleRepository.cs
Hi @wingqing1314,
When I check your code I see from a in _adminRep,
It is wrong usage if the _adminRep is an IRepository.
You should use DbContext in your repository. Do not inject other repositories to another repository, it is not suggested.
Here is an example to you;
var admins = DbContext.Set<Admin>(); // Change the Entity
var units = DbContext.Set<Unit>(); // Change the Entity
var data = from a in admins
join b in units
on a.UnitId equals b.Id
select new AdminUserDto
{
Id = a.Id,
_sex = Sex.female,
DepartmentId = a.DepartmentId,
UnitId = a.UnitId,
UnitName = b.Name
};