12345678910111213141516171819202122232425262728293031323334 |
- using Microsoft.EntityFrameworkCore;
- using MTWorkHR.Core.Entities;
- using MTWorkHR.Core.IDto;
- using MTWorkHR.Infrastructure.Entities;
- using MTWorkHR.Infrastructure.DBContext;
- using MTWorkHR.Core.IRepositories;
- namespace MTWorkHR.Infrastructure.Repositories
- {
- public class ProjectRepository : Repository<Project>, IProjectRepository
- {
- private readonly DbSet<Project> dbSet;
- public ProjectRepository(HRDataContext context) : base(context)
- {
- dbSet = context.Set<Project>();
- }
-
- public async Task<Project> GetByIdWithAllChildren(long id)
- {
- return await dbSet
- .Include(x => x.ProjectTeams)
- .FirstOrDefaultAsync(x => x.Id == id);
- }
- public async Task<Tuple<IQueryable<Project>, int>> GetAllWithChildrenAsync()
- {
- var query = dbSet.Include(x => x.ProjectTeams).AsQueryable();
- var total = await query.CountAsync();
- return new Tuple<IQueryable<Project>, int>(query, total);
- }
- }
- }
|