LogoLogo
  • Dosaic
  • Hosting
    • WebHost
    • Generator
    • Abstractions
  • Plugins
    • Authorization
      • Abstractions
      • Keycloak
    • Endpoints
      • Abstractions
      • RestResourceEntity
    • Handlers
      • Abstractions
      • CQRS
    • Jobs
      • Hangfire
    • Management
      • Unleash
    • Mapping
      • Mapster
    • Messaging
      • Abstractions
      • MassTransit
    • Persistence
      • Abstractions
      • EntityFramework
      • InMemory
      • MongoDb
      • S3
      • VaultSharp
    • Validations
      • Abstractions
      • Attribute
  • Extensions
    • RestEase
    • Sqids
  • Testing
    • NUnit
Powered by GitBook
On this page
  • Installation
  • Appsettings.yml
  • Usage
  1. Plugins
  2. Mapping

Mapster

Dosaic.Plugins.Mapping.Mapster is a plugin that allows other Dosaic components to use dto mapping using Mapster.

Installation

To install the nuget package follow these steps:

dotnet add package Dosaic.Plugins.Mapping.Mapster

or add as package reference to your .csproj

<PackageReference Include="Dosaic.Plugins.Mapping.Mapster" Version="" />

Appsettings.yml

You do not need to configure anything, because the implementation resolver, does this automatically at startup.

Usage

Currently its only implemented to generate the Mapster mapping rules by the "MapFromAttribute" so you can inline all mappings. If it is needed to do more, we need to implement it.


Example:
```csharp
internal class DbModel {
    public string Id {get;set;}
    public string LongName {get;set;}
}

internal class SomeDto {
    public string Id {get;set;}
    [MapFrom<DbModel>(nameof(DbModel.LongName))]
    public string Name {get;set;}
}

// USAGE:
var dbModel = new DbModel { Id = "1", LongName = "LongName" };
var someDto = dbModel.Adapt<SomeDto>();
Console.WriteLine(someDto.Name); // "LongName"
PreviousMappingNextMessaging

Last updated 3 months ago