24 lines
550 B
C#
24 lines
550 B
C#
using System.Threading.Tasks;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace HN.Infrastructure
|
|
{
|
|
public abstract class Repository<TEntity> where TEntity : class
|
|
{
|
|
private readonly HNDbContext _context;
|
|
|
|
protected readonly DbSet<TEntity> Entries;
|
|
|
|
protected Repository(HNDbContext context)
|
|
{
|
|
_context = context;
|
|
Entries = _context.Set<TEntity>();
|
|
}
|
|
|
|
protected async Task AddAsync(params TEntity[] entities)
|
|
{
|
|
await Entries.AddRangeAsync(entities);
|
|
await _context.SaveChangesAsync();
|
|
}
|
|
}
|
|
} |