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
0
votes
1 answer

How unflattening commands to complex types

I'm not yet dependent to either Mapster or AutoMapper. For now I'm using handwritten mappings because I couldn't find a mapper who could do this with smaller code. The problem is how do we map flatten structures to complex objects? I think a lot of…
DJohn
  • 9
  • 2
0
votes
1 answer

Circular reference causing stack overflow with Mapster

Stack overflow exception with Mapster cause running process to terminate. TSource.Adapt()
e03050
  • 1,392
  • 15
  • 12
0
votes
1 answer

Simple Injector and Mapster Dependency Injection setup

The documentation on the Mapster Wiki isnt very good and I cant seem to get it hooked up with Simple Injector. I have this below: container.RegisterSingleton(() => MapperProvider.GetConfiguredMappingConfig()); container.Register
Mike Flynn
  • 22,342
  • 54
  • 182
  • 341
0
votes
1 answer

Mapster - Dynamic property selection or ignore

I have a business need to dynamically select ONLY the properties of a given model that are specified, similar to an OData select clause. I am currently using Mapster's ProjectToType functionality to populate view models from EF Core entities. Is…
Michael Rentmeister
  • 167
  • 1
  • 6
  • 24
0
votes
1 answer

Mapster.Tool Code Generation for Specific Project

I have a Visual Studio solution containing various sample console app projects. One of which is MapsterSample where I am trying out Mapster and following the steps described on GitHub https://github.com/MapsterMapper/Mapster/wiki/Mapster.Tool to…
Patee Gutee
  • 292
  • 2
  • 19
0
votes
1 answer

MapsterMapper map with internal constructor

I'm doing a wrapper for an API and I have my json models which I would map into my entity models with MapsterMapper. I have tried to simply do jsonModel.Adapt() with EntityModel looking like this: public class EntityModel { public int…
Jensyl
  • 25
  • 5
0
votes
1 answer

Mapster with Parent and ChildCollection "reciprocal" navigation properties

So I have "entities" and "dtos". Department has N Employees Employee has 1 (parent) Department. Right now I have no deviation with property names. My EFCore "query" is getting All Departments with an Include (child) Employees. I prefer to isolate my…
granadaCoder
  • 26,328
  • 10
  • 113
  • 146
0
votes
1 answer

Mapster.Tool fails generating mapper

Mapster.Tool fails to generate any code. The problem seems to be a class derived from CosmosClient - which i get from a nuget package. I get this exception: Cannot find library: Microsoft.Azure.Cosmos.Client Unhandled exception.…
Sebastian K
  • 11
  • 1
  • 5
0
votes
1 answer

Mapster, try map to field of class with many constructor without default and fail

I'm try to learn Mapster. I have classes like this class In { public string A; public string B; public string C; } class Out { public Sub Sub; public string C; } class Sub { public string A; public string B; …
srvr4vr
  • 173
  • 1
  • 9
0
votes
1 answer

Mapster from ExpandoObject to Dto - how to prevent setting missing keys to Null in Dto?

I have an object representing an update: var update = new ExpandoObject(); update.AddSafely("Name", "Mary"); This property is part of a dto, like: public class Dto { public string Name {get; set;} public string Other {get; set; } var data =…
FDM
  • 628
  • 6
  • 18
0
votes
1 answer

Mapster - mapping descendant classes from base class

Classes: public class Department { public string Name { get; set; } } public class DepartmentA : Department { public string NameA { get; set; } } public class Employee { public string Name { get; set; } public int Salary { get;…
trubar
  • 3
  • 3
0
votes
1 answer

AmbiguousMatchException on Mapster compile

When I try to compile the mapster configuration, it throws an AmbiguousMatchException in this specific mapping: config.NewConfig() .Map(dest => dest.Id, src => src.Id) .Map(dest => dest.Prop1, src => src.Prop1) …
0
votes
1 answer

Is there a way to Ignore all null values from source during mapping using Mapster when members are IEnumerable

I'm using Mapster 5.3.1 with DI in EF Core 3.1 ... and I have a question.. is there a way to ignore all null values in source member during mapping when both members are IEnumerable and both have identical structure. var tSource = (IEnumerable) var…
0
votes
1 answer

Strategy for mapping strings as dates to datetime using Mapster when strings may be empty?

I'm using Mapster to map values from a dto based on a json object to a Entity Framework data table. The destination class has a field [Column(TypeName = "datetime2(3)")] public DateTime? CorrectBy { get; set; } that is being filled from a…
John S
  • 7,909
  • 21
  • 77
  • 145
0
votes
2 answers

Using Mapster w/DI where should I be putting my mapping?

Using Mapster with the Mapster DI package I also have a static class called MapperConfig that has a static method that does all my dto to viewmodel mapping. public static class MapperConfig { public static void Config() { var tenantId =…
John S
  • 7,909
  • 21
  • 77
  • 145