Files
messengerapi/code/MessengerApi.Db/Repositories/Repository.cs
masiton 4393977389
All checks were successful
Build and Push Docker Image / build (push) Successful in 1m3s
Build and Push Docker Image / docker (push) Successful in 43s
Initial commit carried over from private repo. This is V2.
2025-07-04 21:24:12 +02:00

26 lines
589 B
C#

using MessengerApi.Db.Contracts.Entities;
using MessengerApi.Db.Contracts.Repositories;
using Microsoft.EntityFrameworkCore;
namespace MessengerApi.Db.Repositories
{
public abstract class Repository<T> : IRepository<T> where T : class, IEntity<T>
{
protected readonly DbSet<T> db;
public Repository(DbSet<T> db)
{
this.db = db;
}
public void Add(T entity)
{
this.db.Add(entity);
}
public T GetById(Guid id)
{
return this.db.Single(x => x.Id == id);
}
}
}