{"id":26249748,"url":"https://github.com/noncommunicado/kutcode.automapper.extensions","last_synced_at":"2025-04-24T02:07:30.980Z","repository":{"id":250585207,"uuid":"833058518","full_name":"noncommunicado/KutCode.AutoMapper.Extensions","owner":"noncommunicado","description":"Comfortable In-Type Map Profile Configuration ","archived":false,"fork":false,"pushed_at":"2025-03-17T10:04:38.000Z","size":35,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-30T05:51:15.405Z","etag":null,"topics":["automapper","automapper-alternative","automapper-extension","csharp","dotnet","extensions","net7","net8"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/KutCode.AutoMapper.Extensions","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/noncommunicado.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-07-24T09:16:21.000Z","updated_at":"2025-03-17T10:04:38.000Z","dependencies_parsed_at":"2024-10-30T13:32:39.387Z","dependency_job_id":null,"html_url":"https://github.com/noncommunicado/KutCode.AutoMapper.Extensions","commit_stats":null,"previous_names":["hamaronooo/kutcode.automapper.extensions","noncommunicado/kutcode.automapper.extensions"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noncommunicado%2FKutCode.AutoMapper.Extensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noncommunicado%2FKutCode.AutoMapper.Extensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noncommunicado%2FKutCode.AutoMapper.Extensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noncommunicado%2FKutCode.AutoMapper.Extensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/noncommunicado","download_url":"https://codeload.github.com/noncommunicado/KutCode.AutoMapper.Extensions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250194729,"owners_count":21390229,"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":["automapper","automapper-alternative","automapper-extension","csharp","dotnet","extensions","net7","net8"],"created_at":"2025-03-13T15:49:29.288Z","updated_at":"2025-04-24T02:07:30.963Z","avatar_url":"https://github.com/noncommunicado.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# \u003cimg src=\"./img/icon.png\" style=\"width: 30px\" /\u003e KutCode.AutoMapper.Extensions\n\n.NET library that allows you:    \n- Configure Mappings in the type definition\n- Use inheritance of interfaces for \"default\" mappings, without complex rules\n\n## 📜 Installation\n\n`KutCode.AutoMapper.Extensions` is designed with `net7.0` and higher.\n\nInstall `KutCode.AutoMapper.Extensions` using NuGet Package Manager:\n\n```powershell\nInstall-Package KutCode.AutoMapper.Extensions\n```\n\nOr via the .NET CLI:\n\n```shell\ndotnet add package KutCode.AutoMapper.Extensions\n```\n\nAll versions can be found [here](https://www.nuget.org/packages/KutCode.AutoMapper.Extensions/).\n\n\n## 🚀 Quick Start\n### Basic example\nLet's declare two types:\n```csharp\npublic class SomeEntity\n{\n    public string Value { get;set; }\n}\n\npublic class SomeDto : IMapWith\u003cSomeEntity\u003e // \u003c-- just inherit it\n{\n    public string Value { get;set; }\n}\n```\nUse DI to configure AutoMapper:\n```csharp\nglobal using AutoMapper;\n\nWebApplicationBuilder builder = WebApplication.CreateBuilder(args);\n// just call this to scan All assemblies\nbuilder.Services.AddAllMappings();\n// or select assemblies manually\nbuilder.Services.AddMappings(typeof(Program).Assembly, typeof(Domain).Assembly);\n```\nSo, that's all, now you can map with AutoMapper's `IMapper` as usual:\n```csharp\nSomeDto dto = mapper.Map\u003cSomeDto\u003e(entity);\n```\n----\n### `IMapFrom\u003cT\u003e` and `IMapTo\u003cT\u003e`\n⚠️ Whereas, you can also use those interfaces, which just calls `CreateMap()` if not overrided:\n- `IMapFrom\u003cT\u003e` create map from `T` to implementing class\n- `IMapTo\u003cT\u003e` create map from implementing class to `T`\n\n----\n### Override default mapping\nIf you just inherite interface `IMapWith\u003cT\u003e` - that will created `.ReverseMap()` for two types.  \nSo, you can override default mapping, and set your own behaviour:\n```csharp\npublic class SomeDto : IMapWith\u003cSomeEntity\u003e\n{\n    public string Value { get;set; }\n    // override Map method\n    public void Map(MapProfileDecorator\u003cSomeEntity\u003e decorator)\n    {\n        decorator.Profile.CreateMap\u003cDataDto, DataEntity\u003e()\n            .ForMember(m =\u003e m.Value, opt \n                =\u003e opt.MapFrom(f =\u003e \"SomeOverride\")\n            );\n    }\n}\n```\n----\n### Use multiple interfaces\n```csharp\npublic class SomeDto : IMapWith\u003cSomeEntity\u003e,\n    IMapTo\u003cAnotherOne\u003e, IMapFrom\u003cAndAnotherOne\u003e\n{\n    public string Value { get;set; }\n    \n    // also overrides available for all intrfaces\n}\n```\n----\n\n## ✨ Conclusion\n\n- Use `IMapWith\u003cT\u003e` for reverse mapping\n- Use `IMapFrom\u003cT\u003e` to map from `T` to an implementing type\n- Use `IMapTo\u003cT\u003e` to map from an implementing type to `T`\n\nAll of these interfaces allow you to override the `Map(MapProfileDecorator\u003cT\u003e)` method to customize the mapping.\n\n\n## ☕ Contribution\n\nIf you wanna to buy me a coffee, send any tokens in TON network:  \n💎 `noncommunicado.ton`  \n💎 `UQD0zFgp0p-eFnbL4cPA6DYqoeWzGbCA81KuU6BKwdFmf8jv`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoncommunicado%2Fkutcode.automapper.extensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnoncommunicado%2Fkutcode.automapper.extensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoncommunicado%2Fkutcode.automapper.extensions/lists"}