12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using Microsoft.EntityFrameworkCore;
- using MTWorkHR.Core.IRepositories.Base;
- using MTWorkHR.Infrastructure.Data;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- namespace MTWorkHR.Infrastructure.Repositories
- {
- public class RepositoryLog<T>: IRepositoryLog<T> where T : class
- {
- protected readonly HRDataContext context;
- private readonly DbSet<T> dbSet;
- public RepositoryLog(HRDataContext _Context)
- {
- context = _Context;
- dbSet = context.Set<T>();
- }
- public async Task<T> AddAsync(T entity)
- {
- await dbSet.AddAsync(entity);
- return entity;
- }
- public async Task DeleteAsync(T entity)
- {
- dbSet.Remove(entity);
- }
- public async Task<IReadOnlyList<T>> GetAllAsync()
- {
- return await dbSet.ToListAsync();
- }
- public async Task<T> GetByIdAsync(long id)
- {
- return await context.Set<T>().FindAsync(id);
- }
- public IQueryable<T> AsQueryable()
- {
- return dbSet.AsQueryable<T>();
- }
- }
- }
|