Introduced a `DbConnection` constructor in `JobRunnerDbContext` for Entity Framework 6 to enable in-memory testing with the Effort library. Added conditional compilation to support both .NET Framework 4.8 and .NET 8. Implemented `AddInfrastructureInMemory` in `DependencyExtension` to register services with in-memory databases: - For .NET 4.8, uses Effort's transient connection. - For .NET 8, uses EF Core's in-memory provider. Registered AutoMapper in both methods for object mapping. Added `EntityMappingProfile` to define AutoMapper configurations, enforcing explicit DTO-to-entity mappings. These changes improve testability and maintainability across .NET versions.
23 lines
752 B
C#
23 lines
752 B
C#
using AutoMapper;
|
|
using ECMJobRunner.Domain.Entities;
|
|
|
|
namespace ECMJobRunner.Infrastructure.Mapping
|
|
{
|
|
/// <summary>
|
|
/// AutoMapper profile for entity mappings
|
|
/// </summary>
|
|
public class EntityMappingProfile : Profile
|
|
{
|
|
/// <summary>
|
|
/// Constructor configuring AutoMapper mappings for all entities
|
|
/// </summary>
|
|
public EntityMappingProfile()
|
|
{
|
|
// Note: object -> Entity mappings are intentionally removed
|
|
// AutoMapper cannot map from object type due to reflection limitations
|
|
// Callers should use explicit DTO types and create specific mappings
|
|
// Example: CreateMap<YourDto, CfgProfile>() in your own AutoMapper profile
|
|
}
|
|
}
|
|
}
|