Mapster
Installation
dotnet add package Dosaic.Plugins.Mapping.Mapster<PackageReference Include="Dosaic.Plugins.Mapping.Mapster" Version="" />Configuration
Usage
Basic property rename
public class DbModel
{
public string Id { get; set; }
public string LongName { get; set; }
}
public class ModelDto
{
public string Id { get; set; }
[MapFrom<DbModel>(nameof(DbModel.LongName))]
public string Name { get; set; }
}
// Mapping
var dbModel = new DbModel { Id = "1", LongName = "Hello World" };
var dto = dbModel.Adapt<ModelDto>();
// dto.Name == "Hello World"Nested navigation path
Collection projection — scalar values
Collection projection — object mapping
Null-safe collection mapping
Multiple [MapFrom] attributes on a single property
[MapFrom] attributes on a single propertyEF Core LINQ projection (ProjectToType<T>)
ProjectToType<T>)Features
Last updated