{"id":15108777,"url":"https://github.com/mapstermapper/mapster","last_synced_at":"2025-05-13T15:02:40.073Z","repository":{"id":17540102,"uuid":"20342794","full_name":"MapsterMapper/Mapster","owner":"MapsterMapper","description":"A fast, fun and stimulating object to object Mapper","archived":false,"fork":false,"pushed_at":"2024-06-17T20:46:35.000Z","size":1527,"stargazers_count":4403,"open_issues_count":207,"forks_count":333,"subscribers_count":77,"default_branch":"master","last_synced_at":"2024-12-22T09:47:49.440Z","etag":null,"topics":["c-sharp","codegenerator","fast","mapper","mapping"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MapsterMapper.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-05-30T21:19:14.000Z","updated_at":"2024-12-21T19:35:48.000Z","dependencies_parsed_at":"2023-09-22T04:21:21.406Z","dependency_job_id":"ee4638f5-c907-4dad-94ec-6bb2bfb30c23","html_url":"https://github.com/MapsterMapper/Mapster","commit_stats":{"total_commits":562,"total_committers":50,"mean_commits":11.24,"dds":0.5480427046263345,"last_synced_commit":"04ac871b55828c3909b6cee4764e6fab40db3983"},"previous_names":["eswann/mapster"],"tags_count":52,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MapsterMapper%2FMapster","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MapsterMapper%2FMapster/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MapsterMapper%2FMapster/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MapsterMapper%2FMapster/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MapsterMapper","download_url":"https://codeload.github.com/MapsterMapper/Mapster/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250382037,"owners_count":21421247,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-sharp","codegenerator","fast","mapper","mapping"],"created_at":"2024-09-25T22:40:24.860Z","updated_at":"2025-04-23T06:26:15.145Z","avatar_url":"https://github.com/MapsterMapper.png","language":"C#","readme":"![Mapster Icon](https://cloud.githubusercontent.com/assets/5763993/26522718/d16f3e42-4330-11e7-9b78-f8c7402624e7.png)\n\n## Mapster - The Mapper of Your Domain\nWriting mapping methods is a machine job. Do not waste your time, let Mapster do it.\n\n[![NuGet](https://img.shields.io/nuget/v/Mapster.svg)](https://www.nuget.org/packages/Mapster)\n\n### Installation\nInstall Mapster with the NuGet CLI:\n```\nInstall-Package Mapster\n```\n\nOr use the .NET core CLI to install Mapster:\n```\ndotnet add package Mapster\n```\n\n### Basic usage\n#### Mapping to a new object\nMapster creates the destination object and maps values to it.\n\n```csharp\nvar destObject = sourceObject.Adapt\u003cDestination\u003e();\n```\n\n#### Mapping to an existing object\nYou create the object, Mapster maps to the object.\n\n```csharp\nsourceObject.Adapt(destObject);\n```\n\n#### You can get IMapper instance via dependency injection so you do not have to change code when migrating to mapster from automapper\nAdd Mapster to service collection\n```csharp\nservices.AddMapster();\n```\nAnd use it with DI\n```csharp\npublic class Test\n{\n    public Test(IMapper mapper)\n    {\n        var sourceObject = mapper.Adapt\u003cDestination\u003e();\n    }\n}\n```\n\n#### Queryable Extensions\nMapster also provides extensions to map queryables.\n\n```csharp\nusing (MyDbContext context = new MyDbContext())\n{\n    // Build a Select Expression from DTO\n    var destinations = context.Sources.ProjectToType\u003cDestination\u003e().ToList();\n\n    // Versus creating by hand:\n    var destinations = context.Sources.Select(c =\u003e new Destination {\n        Id = c.Id,\n        Name = c.Name,\n        Surname = c.Surname,\n        ....\n    })\n    .ToList();\n}\n```\n\n#### Generating models \u0026 mappers\nNo need to write your own DTO classes. Mapster provides [Mapster.Tool](https://github.com/MapsterMapper/Mapster/wiki/Mapster.Tool) to help you generating models. And if you would like to have explicit mapping, Mapster also generates mapper class for you.\n\n```csharp\n[AdaptTo(\"[name]Dto\"), GenerateMapper]\npublic class Student {\n    ...\n}\n```\n\nThen Mapster will generate:\n```csharp\npublic class StudentDto {\n    ...\n}\npublic static class StudentMapper {\n    public static StudentDto AdaptToDto(this Student poco) { ... }\n    public static StudentDto AdaptTo(this Student poco, StudentDto dto) { ... }\n    public static Expression\u003cFunc\u003cStudent, StudentDto\u003e\u003e ProjectToDto =\u003e ...\n}\n```\n\n### What's new\n- [Fluent API for code generation](https://github.com/MapsterMapper/Mapster/wiki/Fluent-API-Code-generation)\n- [Automatically generate mapping code on build](https://github.com/MapsterMapper/Mapster/wiki/Mapster.Tool)\n- [Define setting to nested mapping](https://github.com/MapsterMapper/Mapster/wiki/Config-for-nested-mapping)\n- [`ISet`, `IDictionary`, `IReadOnlyDictionary` support](https://github.com/MapsterMapper/Mapster/wiki/Data-types#collections)\n- [`EmptyCollectionIfNull`, `CreateNewIfNull` DestinationTransform](https://github.com/MapsterMapper/Mapster/wiki/Setting-values#transform-value)\n- [Several fixes](https://github.com/MapsterMapper/Mapster/releases/)\n- New plugins\n  - [Immutable collection support](https://github.com/MapsterMapper/Mapster/wiki/Immutable)\n\n### Why Mapster?\n#### Performance \u0026 Memory efficient\nMapster was designed to be efficient on both speed and memory. You could gain a 4x performance improvement whilst using only 1/3 of memory.\nAnd you could gain up to 12x faster performance with\n- [Roslyn Compiler](https://github.com/MapsterMapper/Mapster/wiki/Debugging)\n- [FEC](https://github.com/MapsterMapper/Mapster/wiki/FastExpressionCompiler)\n- Code generation\n\n|                    Method |      Mean |    StdDev |     Error |      Gen 0 | Gen 1 | Gen 2 | Allocated |\n|-------------------------- |----------:|----------:|----------:|-----------:|------:|------:|----------:|\n|           'Mapster 6.0.0' | 108.59 ms |  1.198 ms |  1.811 ms | 31000.0000 |     - |     - | 124.36 MB |\n|  'Mapster 6.0.0 (Roslyn)' |  38.45 ms |  0.494 ms |  0.830 ms | 31142.8571 |     - |     - | 124.36 MB |\n|     'Mapster 6.0.0 (FEC)' |  37.03 ms |  0.281 ms |  0.472 ms | 29642.8571 |     - |     - | 118.26 MB |\n| 'Mapster 6.0.0 (Codegen)' |  34.16 ms |  0.209 ms |  0.316 ms | 31133.3333 |     - |     - | 124.36 MB |\n|     'ExpressMapper 1.9.1' | 205.78 ms |  5.357 ms |  8.098 ms | 59000.0000 |     - |     - | 236.51 MB |\n|       'AutoMapper 10.0.0' | 420.97 ms | 23.266 ms | 35.174 ms | 87000.0000 |     - |     - | 350.95 MB |\n\n\n\n#### Step into debugging\n\n[Step-into debugging](https://github.com/MapsterMapper/Mapster/wiki/Debugging) lets you debug your mapping and inspect values just like your code.\n![image](https://cloud.githubusercontent.com/assets/5763993/26521773/180427b6-431b-11e7-9188-10c01fa5ba5c.png)\n\n#### Code Generation\nCode generation allows you to\n- Validate mapping at compile time\n- Getting raw performance\n- Seeing your mapping code \u0026 debugging\n- Finding usage of your models' properties\n\nThere are currently two tools which you can choose based on your preferences.\n* [Mapster.Tool](https://github.com/MapsterMapper/Mapster/wiki/Mapster.Tool) NEW!\n* [TextTemplate](https://github.com/MapsterMapper/Mapster/wiki/TextTemplate)\n\n### Change logs\nhttps://github.com/MapsterMapper/Mapster/releases\n\n### Usages\n* [English](https://github.com/MapsterMapper/Mapster/wiki)\n* [中文文档](https://github.com/rivenfx/Mapster-docs) (sp thx to [@staneee](https://github.com/staneee))\n\n### Acknowledgements\n\n[JetBrains](https://www.jetbrains.com/?from=Mapster) kindly provides Mapster with a free open-source licence for their Resharper and Rider.\n- **Resharper** makes Visual Studio a much better IDE\n- **Rider** is fast \u0026 powerful cross platform .NET IDE\n\n![image](https://upload.wikimedia.org/wikipedia/commons/thumb/1/1a/JetBrains_Logo_2016.svg/121px-JetBrains_Logo_2016.svg.png)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmapstermapper%2Fmapster","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmapstermapper%2Fmapster","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmapstermapper%2Fmapster/lists"}