26ff8d9b4f
Set up repository with legacy .NET Framework 4.8 source (OLD/), new .NET 10 Blazor solution (NEW/), OpenSpec specifications, documentation, and project configuration.
3.3 KiB
3.3 KiB
Implement Data Access
Summary
Implement the data access layer with repository interfaces and implementations for accessing SQL Server (LotFinderDB), JDE Oracle, and CMS Oracle databases. This provides the foundation for all data operations in the migrated application.
Scope
In Scope
IDbConnectionFactoryinterface andDbConnectionFactoryimplementationILotFinderRepositoryinterface with all SQL Server cache methodsIJdeRepositoryinterface with all JDE Oracle query methodsICmsRepositoryinterface with CMS MIS data methodsLotFinderRepository,JdeRepository,CmsRepositoryimplementationsDataAccessOptionsconfiguration class- Custom exception hierarchy (
DataAccessException,ConnectionException,QueryException,DataAccessTimeoutException) AddDataAccessservice registration extension method- SQL queries as embedded resources or compile-time constants
- Unit tests for repository methods
Out of Scope
- Database schema changes (handled by migrate-database-schema)
- Data sync scheduling (Phase 5: data-sync)
- Search processing logic (Phase 6: search-processing)
- Azure Key Vault integration (will use .NET Secret Manager for local dev)
Motivation
The legacy data access layer uses static partial classes which are difficult to test and tightly coupled. The new design provides:
- Interface-based repositories for dependency injection and testability
- Connection factory abstraction for consistent connection management
- Async-first design with
IAsyncEnumerable<T>for memory-efficient streaming - Typed exceptions for consistent error handling
- Configurable timeouts via options pattern
Acceptance Criteria
- All three repository interfaces defined with methods matching the spec
IDbConnectionFactoryprovides connections for all four database connections (LotFinderDB, JDE, JDE Stage, CMS)- All repository implementations use Dapper for query execution
- JDE/CMS streaming queries use
IAsyncEnumerable<T>withQueryUnbufferedAsync - All methods accept
CancellationTokenparameter - Custom exceptions thrown on errors (never return null/empty on error)
AddDataAccessextension method registers all services with appropriate lifetimes- SQL injection prevented via whitelist validation in
RebuildIndicesAsync - Unit tests pass with mocked dependencies
openspec validate implement-data-access --strictpasses
Dependencies
migrate-database-schema- Database schema must exist for repository queries- NuGet packages:
Microsoft.Data.SqlClient,Oracle.ManagedDataAccess.Core,Dapper
Risks
| Risk | Mitigation |
|---|---|
| Oracle driver compatibility | Test early with Oracle.ManagedDataAccess.Core against target databases |
| Query translation errors | Copy SQL exactly from legacy, validate with Codex MCP review |
| Streaming memory issues | Use QueryUnbufferedAsync for all large result sets |
| Connection pooling misconfiguration | Use default ADO.NET pooling, document connection string settings |
Related Specs
data-access- All repository interface and method definitionsdomain-models- Entity types returned by repositoriesdatabase-schema- SQL Server tables accessed by LotFinderRepository