### 📌 **Repository Interfaces (Domain/Repositories)** ```csharp namespace Domain.Repositories { public interface IRepository where T : class { Task GetByIdAsync(int id); Task> GetAllAsync(); Task AddAsync(T entity); void Remove(T entity); } } ``` ```csharp namespace Domain.Repositories { public interface IUnitOfWork { Task CompleteAsync(); } } ``` ### 📌 **Repository Pattern (Infrastructure/Persistence/Repositories)** ```csharp using Domain.Repositories; using Microsoft.EntityFrameworkCore; namespace Infrastructure.Persistence.Repositories { public class Repository : IRepository where T : class { protected readonly AppDbContext _context; protected readonly DbSet _dbSet; public Repository(AppDbContext context) { _context = context; _dbSet = context.Set(); } public async Task GetByIdAsync(int id) => await _dbSet.FindAsync(id); public async Task> GetAllAsync() => await _dbSet.ToListAsync(); public async Task AddAsync(T entity) => await _dbSet.AddAsync(entity); public void Remove(T entity) => _dbSet.Remove(entity); } } ``` ### 📌 **Unit of Work Implementation** ```csharp using Domain.Repositories; using System.Threading.Tasks; namespace Infrastructure.Persistence { public class UnitOfWork : IUnitOfWork { private readonly AppDbContext _context; public UnitOfWork(AppDbContext context) { _context = context; } public async Task CompleteAsync() { return await _context.SaveChangesAsync(); } } } ```