I use Mapster Mapper to project from domain models to DTOs.
That works perfectly, but now I had to use a GroupBy/Select and that breaks my code:
public class Document
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public Guid Id {…
I'm using following code to map my classes, and it is working perfectly in one direction, but I want to use same approach to automatically use TwoWays (reverse) mapping, but that is not working using second portion of code:
static string…
MapsterMapper/Mapster 7.3.0
EFCore 7.0.5
asp.net core 7.0.0
I have two generic type in my BuzService class, one is TModel and other one is TEntity.
TModel is a DTO class, TEntity is an entity class.
I have a method in the service class
public…
I am trying to Map a request object plus and extra string to another object using C# Mapster. However I cant seem to find a solution to do it.
The user sends a request and the controller recieves a object from this class
public record…
MapsterMapper/Mapster
MapsterMapper/Mapster 7.3.0
EFCore 7.0.5
asp.net core 7.0.0
Entity Class
public class Setting
{
[Key]
public Guid Id {get;set;}
public string Name {get;set;}
public string Value {get;set;}
}
Dto…
I am having an issue with mapping nested collections using Mapster in .NET 7. The mapping seems to fail for the second-level collection (Bs inside A). This is surprising because, during debugging, I can see that A does have Bs with Cs.
Here are my…
I have multiple classes implementing a base class, e.g.:
public abstract class Step
{
public StepId Id {get; set;}
public string Text {get; set;
public StepType Type {get;set;}
}
public class SelectionStep : Step
{
public…
how can I apply predicates after projecting to a type with mapster?
so I have this
public sealed class PRGeneric : where T : class
{
public async Task> GetPaginated(
Expression>? OrderField,
bool…
Bottom line, after reviewing comments:
Not possible with Mapster, and it's not Mapster's "mandate" - it belongs to business logic (before/after mapping).
Original question:
Is there a way to exclude/ignore records/entries according to their…
I have two way config for mapping using Mapster:
public static TwoWaysTypeAdapterSetter ClientConfig =>
TypeAdapterConfig
.NewConfig()
.TwoWays()
.Map(dest…
I have the following class:
public class FooDto
{
public string Secret { get; set; }
}
I have configured the mapping as follows:
config.NewConfig() Map(dest => dest.Secret, src =>…
Decided to use Mapster instead of writing my own conversion/mapping methods. Haven't found anything that would suffice my use case on their github wiki.
I have an instance of Dictionary where keys are property names of target type…
I have a class with a property that is a list of child class.
I'm trying to map the Id of the parent class to a property in each item of the list.
Example (c#):
// Source.
public class Person
{
public string Id { get; init; }
public string…
I'd like to create a dto that has a collection of reference id's to the object that is stored in a collection in the entity. As illustrated below:
public class MainEntity{
public int Id {get;set;}
public ICollection Others…
I have three libraries, each containing a namespace for models, and all the models in each library are effectively identical in the data they hold--they have minor differences in how they are implemented, but I don't have control over that as the…