Files
DbFirst/DbFirst.Domain/Repositories/ICatalogRepository.cs
OlgunR 45e5327148 Add ICatalogRepository interface and design comments
Added ICatalogRepository with async catalog retrieval methods. Included detailed comments on repository design patterns and clean architecture layer placement, recommending interface stays in Domain. Fixed file encoding (added BOM).
2026-01-19 09:12:16 +01:00

34 lines
2.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using DbFirst.Domain.Entities;
namespace DbFirst.Domain.Repositories;
// TODO: instead of creating interface per entity, consider using generic repository pattern (eg. IRepository<T>) to reduce code duplication.
/* Copilot's Response:
A generic Repository<T> isnt really worthwhile here:
• Reads from the view are generic, but inserts/updates/deletes go through stored procedures with special parameters/output GUIDs.Youd need lots of exceptions/overrides—little gain.
• Operations arent symmetric (separate procs for insert/update/delete with output handling and reload), so a one-size-fits-all CRUD pattern doesnt fit well.
• Better to keep the specialized repo.If you want reuse, extract small helpers (e.g., for proc calls/output parameters/reload) instead of forcing a generic repository. */
// TODO: move to application layer as a part of clean architecture
/* Copilot's Response:
• Common: Keep the interface in the Domain layer, implementation in Infrastructure. Domain defines the data access contract, Infrastructure provides the implementation.
That matches typical DDD/Clean Architecture.
• Alternative: Move the interface to the Application layer. Then only Application depends on Infrastructure, Domain stays isolated from infra contracts.
Pro: Domain contains only models/rules.
Con: If Domain logic needs repos, it would depend on Application, weakening the layer separation.
Recommendation: Keep the interface in Domain. Its conventional, clean, and avoids a Domain -> Application dependency. Implementation stays in Infrastructure. */
public interface ICatalogRepository
{
Task<List<VwmyCatalog>> GetAllAsync(CancellationToken cancellationToken = default);
Task<VwmyCatalog?> GetByIdAsync(int id, CancellationToken cancellationToken = default);
Task<VwmyCatalog?> GetByTitleAsync(string title, CancellationToken cancellationToken = default);
Task<VwmyCatalog> InsertAsync(VwmyCatalog catalog, CancellationToken cancellationToken = default);
Task<VwmyCatalog?> UpdateAsync(int id, VwmyCatalog catalog, CancellationToken cancellationToken = default);
Task<bool> DeleteAsync(int id, CancellationToken cancellationToken = default);
}