Replace AutoMapper with explicit FromModel() extension methods in V3 API#3327
Draft
Copilot wants to merge 4 commits into
Draft
Replace AutoMapper with explicit FromModel() extension methods in V3 API#3327Copilot wants to merge 4 commits into
Copilot wants to merge 4 commits into
Conversation
…sions Agent-Logs-Url: https://github.com/DFE-Digital/teaching-record-system/sessions/9e668dcc-ce78-4618-9b92-f8bb5a268aea Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com>
Agent-Logs-Url: https://github.com/DFE-Digital/teaching-record-system/sessions/3a4249ae-4472-479b-8aa6-d235ea07e1f7 Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com>
Agent-Logs-Url: https://github.com/DFE-Digital/teaching-record-system/sessions/0545de99-aeab-42a0-8aee-27777a5759a2 Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com>
…s, delete MapperProfiles Agent-Logs-Url: https://github.com/DFE-Digital/teaching-record-system/sessions/a875af84-2c87-44ae-a2f1-7ee00dbce2b8 Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
gunndabad
April 25, 2026 09:44
View session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
AutoMapper adds implicit magic that makes mapping logic hard to trace. Replacing it with explicit static
FromModel()methods makes the data flow obvious and removes a runtime dependency on reflection-based mapping.Changes proposed in this pull request
Removed AutoMapper infrastructure:
MapperProfile.csfiles across V20240101–V20260416AutoMapperNuGet package referenceglobal using AutoMapper,AddAutoMapper()service registration, and theITypeConverter<,>Scrutor scanInfrastructure/Mapping/OptionMapper.cs(generic Option/OneOf type converters no longer needed)Added explicit mapping:
FromModel()factory methods on all V3 response records (e.g.GetPersonResponse.FromModel(result))TrnRequestInfo,QtsInfo, alert types, induction info, routes-to-professional-status, etc.TeachingRecordSystem.Apiwhere they reference Api-layer types, and inTeachingRecordSystem.Corewhere they reference only Core typesUpdated all V3 controllers to drop
IMapperconstructor injection and callFromModel()directly:Guidance to review
FromModel()implementation; look for version-specific field additions (e.g.AwardedOrApprovedCountadded in V20250327'sQtsInfo)QtsInfo.FromModel()in V20240814 vs V20250327), the mapping is inlined directly in the response record rather than using an extension methodV20250627/DtoExtensions.csin the Api project handles the richer route-to-professional-status mapping that references both Postgres model types and Implementation DTOsChecklist