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