Questions tagged [mapster]

Mapster is an open source object mapper for .NET,

Mapster is an open source object mapper for .NET.

https://github.com/eswann/Mapster

114 questions
2
votes
0 answers

Mapster generation output directory

The structure of the project looks so that for each entity a separate folder is allocated, which stores the mapper interface, but the generation occurs in the directory above. I need to make the mapper class be generated in the same directory as the…
Дед
  • 21
  • 2
2
votes
2 answers

Mapster - Map non-nullable type to nullable type

I am using mapster to map between entities and DTOs. I have noticed it will not map a Guid? to a Guid (or vice-versa) even if I add it explicitely to a mapping register like such : public sealed class HostConversionMappingRegister : IRegister { …
Martin
  • 1,977
  • 5
  • 30
  • 67
2
votes
2 answers

Mapster not mapping members of generic class inherited from generic list

I'm having difficulties getting all members mapped in the following scenario: I have a class that inherits from List: public class PagedList : List { public int CurrentPage { get; private set; } public int TotalPages { get; private…
Peter Rundqvist
  • 275
  • 3
  • 18
2
votes
1 answer

Mapper Mapster - How to unit test config?

I come here because i dont find the answer online :/ I would like to test my configuration of Mapster to avoid miss mapping which happens at developpement time. But i dont find how to implement that with Mapster lib. Any clue ? Regards,
Wazzouille
  • 43
  • 6
2
votes
0 answers

Mapping to multiple derived classes with Mapster

I'm trying to map from one hierarchy to another. Both my parent classes are abstracts as I'd never need to instantiate them, only their children. I would like to use a single mapping config the constructor of each child rather than create mapping…
Jester1811
  • 23
  • 5
2
votes
0 answers

How to append a value to an existing value

Using mapster and have the following problem https://github.com/MapsterMapper/Mapster I have to class and a dto class. public class Client { public string Requirements { get; set; } } public class ClientDto { public bool RequirePkce { get;…
2
votes
2 answers

Mapster context is null in nested mappings

How I can use MapContext.Current in nested mappings? For example: public class Foo { public string Name { get; set; } } public class Bar { public string Name { get; set; } } public class Src { public IEnumerable Foos { get; set; }…
Krzysztof
  • 498
  • 5
  • 23
2
votes
0 answers

How to override default mapping using mapster

I would like to have a default mapping used always and then I would like to be able to override it when required. Here is the modified example code public SchoolController(IMapper mapper, SchoolContext context) { _mapper = mapper; …
Petr S
  • 21
  • 1
2
votes
1 answer

Mapster Dependency Injection via Autofac

As per Mapster documentation https://github.com/MapsterMapper/Mapster/wiki/Dependency-Injection I am supposed to do the following: public void ConfigureServices(IServiceCollection services) { ... var config = new TypeAdapterConfig(); …
Patee Gutee
  • 292
  • 2
  • 19
2
votes
1 answer

Map one Class properties to two different class properties using Mapster

I have 3 classes with the name of Employee, EmployeeTwo, and EmployeeThree, I wanted to map Employee to EmployeeTwo and Employee to EmployeeThree. Following are the Classes. I also have tried to define the AdaptMember attribute on the Employee Class…
Umair Anwaar
  • 1,130
  • 9
  • 27
2
votes
2 answers

Mapster mapping issue. Mapping a list of objects to a list of strings

I am trying to map a service model to a view model using Mapster. My service model contains a list of strings. My View Model contains a list of type RolesViewModel. RolesViewModel has a string property named RoleName. Below are my models public…
j9070749
  • 815
  • 2
  • 11
  • 22
2
votes
1 answer

Mapster Adpat not working

I`m trying to make a select in form-control.
Pedro Franco
  • 1,926
  • 1
  • 15
  • 37
1
vote
1 answer

Mapping Entity Framework Core graph using Mapster makes list items Detached instead of modified

I am using Mapster mapper and EF Core, and I have a Request entity that has many Materials. I am fetching the graph from the database as a tracked graph and using Mapster I map dto to the EF object graph as follows: dto.Adapt(requestGraph); It…
Simple Code
  • 2,354
  • 2
  • 27
  • 56
1
vote
1 answer

MapsterMapper mapping base class

I am using Mapster for mapping my objects. I have the the following code: public sealed class User : AggregateRoot { public string FirstName { get; } public string LastName { get; } public string Email { get; } public string…
1
vote
0 answers

Mapster injection

I use mapster and its code generation. I have models like this: public class Device { public Guid Id { get; set; } public User User { get; set; } } public class User { public Guid Id { get; set; } } And the same models for Dto…