CompanyRepository.cs 804 B

1234567891011121314151617181920212223242526272829
  1. using Microsoft.EntityFrameworkCore;
  2. using MTWorkHR.Core.Entities;
  3. using MTWorkHR.Core.IDto;
  4. using MTWorkHR.Core.IRepositories;
  5. using MTWorkHR.Infrastructure.Entities;
  6. using MTWorkHR.Infrastructure.DBContext;
  7. namespace MTWorkHR.Infrastructure.Repositories
  8. {
  9. public class CompanyRepository : Repository<Company>, ICompanyRepository
  10. {
  11. private readonly DbSet<Company> dbSet;
  12. public CompanyRepository(HRDataContext context) : base(context)
  13. {
  14. dbSet = context.Set<Company>();
  15. }
  16. public async Task<Company> GetByIdWithAllChildren(long id)
  17. {
  18. return await dbSet
  19. .Include(x => x.City)
  20. .Include(x => x.Country)
  21. .FirstOrDefaultAsync(x => x.Id == id);
  22. }
  23. }
  24. }