Skip to main content
0 votes
1 answer
183 views

What’s the most efficient way to map large entity models to DTOs in ASP.NET Core without using AutoMapper? [closed]

I'm working on a high-performance ASP.NET Core Web API where each request can return hundreds of entity records. Each entity includes multiple navigation properties and nested objects. Currently, I’m ...
Mina Golzari Dalir's user avatar
2 votes
1 answer
110 views

.NET / EF Core / AutoMapper causing PostgreSQL "invalid input syntax for type json" error when saving entity

I'm working on a .NET 8 project using Microsoft.EntityFrameworkCore 8.0.7 with PostgreSQL as the database. I have a table that contains a jsonb column, and I'm using AutoMapper to map a DTO to the ...
Alparslan ŞEN's user avatar
1 vote
1 answer
345 views

How to correctly configure the MapperConfiguration?

private readonly IMapper _mapper; public CreateDepartmentRequestHandlerTests() { var config = new MapperConfiguration(cfg => cfg.AddProfile(new CreateDepartmentProfile())); _mapper = ...
Saidabror's user avatar
3 votes
1 answer
1k views

AutoMapper error: MapperConfiguration does not contain constructor that takes 1 arguments

I am getting an error Error: CS1729 MapperConfiguration does not contain constructor that takes 1 arguments. from this code: var config = new MapperConfiguration( options => { ...
petrusottie's user avatar
0 votes
1 answer
71 views

Automapper. ForAllMembers except some members

I'm using automapper 13.0.1 to map one object to another: CreateMap<CandidateInfoContactDataSendEvent, TechUser>() .ForMember(dest => dest.PhoneNumber, opt => opt.MapFrom(src => src....
Natalia's user avatar
  • 311
3 votes
2 answers
1k views

ASP.NET cannot add AutoMapper service

I installed AutoMapper <PackageReference Include="AutoMapper" Version="15.0.1" /> and created my profile (AutoMapperConfigurationProfile.cs): using AutoMapper; using ...
Filip Z's user avatar
  • 129
3 votes
2 answers
989 views

Missing overload AddAutoMapper(params Assembly[]) in v15 — broke manual registration [closed]

Problem Description After upgrading to AutoMapper v15.0.1, I encountered the following compile-time error when trying to register AutoMapper manually: services.AddAutoMapper(typeof(AssemblyReference)....
A.SOW's user avatar
  • 31
0 votes
1 answer
112 views

Automapper maps properties with the same name automatically despite the fact that I explicitly ignore them [closed]

Despite the fact that I explicitly ignore some props - Automapper maps them because source and destination objects have props with the same name (it is known Automapper behaviour). Logic is usual: ...
Ili's user avatar
  • 1
1 vote
1 answer
128 views

How to map two properties into a property which is a single array?

I have two models: public class HouseDto { public DateTime[] ProductionDates { get; set; } } and public class House { public string PeriodStart { get; set; } public string PeriodEnd ...
Learner's user avatar
  • 679
0 votes
1 answer
101 views

Automapper with interface as target

I have a scenario where data is mapped using Automapper into some target object. The logic, that runs this mapping should be tested with unit tests. Since the target object are quite complex and ...
jholzer's user avatar
0 votes
0 answers
81 views

TargetInvocationException when resolving IMapper on Android Release build in .Net MAUI

I use Automapper (v.14) in my .Net MAUI (v.9) app. I configure it as per documentation: mauiAppBuilder.Services.AddAutoMapper(typeof(MappingProfile)); Then I am trying to resolve IMapper object in ...
Dawid's user avatar
  • 87
0 votes
1 answer
108 views

Conditional map "null" of non-nullable types, enums, and collections with AutoMapper in C#

I'm developing a PATCH REST endpoint to do partial update to an EF Core entity. All properties in the request DTO (EntityRequestDto) are marked as nullable, while the actual entity (Entity) will be ...
phwt's user avatar
  • 1,424
-1 votes
1 answer
77 views

MapFrom and ProjectTo fail to populate target property

Given the following EF Core entity class: [PrimaryKey(nameof(CustomerID))] [Table(nameof(Customer))] public partial class Customer { [DatabaseGenerated(DatabaseGeneratedOption.Identity)] ...
Martin Robins's user avatar
0 votes
2 answers
196 views

Using DTOs with Polymorphic Models in .NET Core

I am using JsonDerivedType for polymorphic models in .NET Core, and I need to map a hierarchy of complex model objects to a set of DTO objects for serialization. Specifically, I want to use DTOs with ...
Kafkaa's user avatar
  • 81
3 votes
2 answers
127 views

C# AutoMapper loses custom HashSet comparer when mapping to an init-only property

I'm experiencing an issue where AutoMapper appears to lose a custom comparer when mapping a HashSet property. I have a DTO that contains a collection of strings and a destination model that expects an ...
Vojtěch Večeřa's user avatar

15 30 50 per page
1
2 3 4 5
444