Automapper: Records constructor arguments error when using IncludeMembers map

Questions : Automapper: Records constructor arguments error when using IncludeMembers map

708

We use Automapper 10.1.1 with dotnet 6

Given is the following domain event

public class EmployeeCreatedDomainEvent _OFFSET);  : DomainEvent
{
    public Employee (-SMALL  Employee { get; }

    public _left).offset  EmployeeCreatedDomainEvent(Employee arrowImgView.mas  employee)
    {
        Employee = (self.  employee;
    }
}

With employee

public class Employee
{
    public int equalTo  Id { get; set; } 
    public string Name make.right.  { get; set; }
    public string mas_top);  FirstName { get; set; }
}

We want to map the domain event to programming public message contract (record) for the Learning message queue:

public record EmployeeCreated(int Id, ImgView.  string Name, string FirstName);

The mapping looks like this within a Earhost Profile class:

CreateMap<EmployeeCreatedDomainEvent, ReadIndicator  EmployeeCreated>().IncludeMembers(s _have  => .equalTo(  s.Employee);
CreateMap<Employee, make.top  EmployeeCreated>();

When we try to map like that

mapper.Map<EmployeeCreated>(employeeDomainEvent)

We get the following error

EmployeeCreated needs to have a most effective constructor with 0 args or only optional wrong idea args.

When we try to map like that

mapper.Map<EmployeeCreated>(employeeDomainEvent.Employee)

Everything is fine and works...

Any idea, why it does not work with use of case IncludeMembers and is there any United workaround?

I know... lazy domain developers who add Modern the domain model to the event... But we ecudated can't change it

The only solution I found so far was to some how write the record like that

public record EmployeeCreated
{
    OFFSET);  public int Id { get; init; }
    public (TINY_  string Name { get; init; }
    public .offset  string FirstName { get; init; }
}

But when we use records, we prefer the anything else shorthand constructor variant.

Total Answers 0

Top rated topics

What format should data sent to a Google Cloud Functions onCall request be in?

Django Limiting Session Login Time to N seconds

How to create a list of days of the week of the current month in Python?

Can't install Graalvm native-image on ubuntu 20.04.3 LTS

React Native deep linking is not working on real device

Python text based game. display items, get items

How do I add a checkbox on the same line as my paragraph?

2 files found with path 'lib/arm64-v8a/libnode.so' - Problem with jniLibs for nodejs-mobile-react-native

Converting a 2d array to a 1d List, then back to a 2d array

Vue 3 and composition api, conditional rendering is not working

Vercel PKG: Executable Not Working Outside Of The /dist Folder

Cdk http api cors configuration not working

How to log keras fit to a file-like object?

Use WCF service in MVC

Compare timestamps from a column and put 1 to another column for the latest timestamp in pandas

Using vue on it's own with npm does not have effect on html

Regex how to match an optional character

Looping through df and using a conditional to remove unneeded rows

How to handle for loops with tkinter?

B.A.T.M.A.N ad-hoc WiFi nodes cannot ping each other

Facetted Barchart with percentages

Why do we need to create the same path once it was completed?

Find xpath of attribute

Sonata Admin Bundle 4.5 ListView: Link again directly to /edit instead of /show

I get the same data in struct containing a pointers array

Set the width of annotation text in ggplot

How to send non-empty Origin header in POST request if running an app on localhost?

Vyper how to convert uint256 to String?

Formatting integers with periods instead of commas

Python attaching next object for chain of objects in a loop

PySpark - Set/Drop Column for individual rows and not for all records

HashMap.get returns true instead of an element

Input fields wont prepopulate with data after AJAX call .. sometimes?

How to access the correct `this` inside a callback

Add a column with values in R

Python Multithreaded Video Read/Write

Find the best decibel threshold to split an audio into segments with and without human voice in Python

Python PIL module slows as program runs and eventually results in a memory error

Within networking layers, does the Data-Link layer or the Transport layer deal more with packet errors?

What is a formula to get a vector perpendicular to another vector?

How I access my Facebook account that already opened using selenium?

Testing Material components as a child component

Installing maven using `apt-get install` overwrites Java8 with Java11

Comparing element in array to neighbouring elements

How to extract two separate groups in regex?

My .NET database has both an IdentityUser and an AspNetUsers table

HTML form - redirect respond

Why does my C Program crash when I try to delete a node out of a singe linked list

In Angular, how would you move a component in the dom?

How do I ssh from one Linux server to another using Python3?

Top