fix: include Release nav on all TrackRepository query paths; add unique constraint on release(title, artist)

This commit is contained in:
daniel-c-harvey
2026-06-11 14:48:52 -04:00
parent f767d288c5
commit 70d4a87cd5
6 changed files with 246 additions and 7 deletions
@@ -26,6 +26,16 @@ public class TrackRepository : Repository<DeepDrftContext, TrackEntity>
_context = context;
}
// Override base GetByIdAsync to include the Release navigation. Without this, the base
// Query has no .Include, so Release is null on every entity (no lazy-loading proxies).
public override async Task<TrackEntity?> GetByIdAsync(long id)
=> await Query.Include(t => t.Release).FirstOrDefaultAsync(e => e.Id == id);
// Override base GetAllAsync for the same reason — include Release so callers (e.g.
// TrackManager.GetAll) receive fully-populated entities without a separate query.
public override async Task<IEnumerable<TrackEntity>> GetAllAsync()
=> await Query.Include(t => t.Release).ToListAsync();
// Lookup by vault entry key. The base Repository<> only exposes id-based queries, so this
// uses Query (soft-delete filtered) rather than the raw DbSet. Includes Release so the
// converter can project the release-cardinal fields.