{"id":22938417,"url":"https://github.com/jacraig/objectcartographer","last_synced_at":"2025-08-12T18:33:20.960Z","repository":{"id":141486557,"uuid":"373302849","full_name":"JaCraig/ObjectCartographer","owner":"JaCraig","description":"ObjectCartographer is a high-performance, convention-based C# object-to-object mapping library designed to simplify the process of copying data between objects. It eliminates the tedious task of manually writing code for data copying by providing a developer-friendly approach.","archived":false,"fork":false,"pushed_at":"2024-10-29T09:45:20.000Z","size":17961,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-29T11:44:04.862Z","etag":null,"topics":["data-conversion","object-mapping","object-to-object"],"latest_commit_sha":null,"homepage":"https://jacraig.github.io/ObjectCartographer/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JaCraig.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-02T21:05:28.000Z","updated_at":"2024-10-29T09:45:23.000Z","dependencies_parsed_at":"2023-09-23T02:17:40.780Z","dependency_job_id":"77b01457-a79c-470e-8e06-f159a44488f9","html_url":"https://github.com/JaCraig/ObjectCartographer","commit_stats":null,"previous_names":[],"tags_count":61,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JaCraig%2FObjectCartographer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JaCraig%2FObjectCartographer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JaCraig%2FObjectCartographer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JaCraig%2FObjectCartographer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JaCraig","download_url":"https://codeload.github.com/JaCraig/ObjectCartographer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229700215,"owners_count":18109937,"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":["data-conversion","object-mapping","object-to-object"],"created_at":"2024-12-14T12:17:52.929Z","updated_at":"2024-12-14T12:17:53.355Z","avatar_url":"https://github.com/JaCraig.png","language":"C#","readme":"# ObjectCartographer\n\n[![.NET Publish](https://github.com/JaCraig/ObjectCartographer/actions/workflows/dotnet-publish.yml/badge.svg)](https://github.com/JaCraig/ObjectCartographer/actions/workflows/dotnet-publish.yml) [![Coverage Status](https://coveralls.io/repos/github/JaCraig/ObjectCartographer/badge.svg?branch=main)](https://coveralls.io/github/JaCraig/ObjectCartographer?branch=main)\n\nObjectCartographer is a fast, convention based, and developer friendly object to object mapper. It's designed to simplify your life and remove the drudgery of writing code to copy data from one object to another.\n\n## Setting Up the Library\n\nRegister ObjectCartographer with your IoC container during startup. Example code:\n\n   ```csharp\n   ServiceProvider? ServiceProvider = new ServiceCollection().RegisterObjectCartographer()?.BuildServiceProvider();\n   ```\n\nor\n\n   ```csharp\n   ServiceProvider? ServiceProvider = new ServiceCollection().AddCanisterModules()?.BuildServiceProvider();\n   ```\n\nAs the library supports [Canister Modules](https://github.com/JaCraig/Canister). With that ObjectCartographer will automatically register any converters found in your application and work with your DI system if you are using one, allowing you to access the DataMapper object at run time if you need to. Otherwise if you are not using one, you can simply use the extension methods and it will wire itself up.\n\n## Basic Usage\n\nOnce the initial setup is done, we need to map our objects to each other. This is accomplished in a number of different ways. First by using the DataMapper class:\n\n    DataMapper.Map\u003cMyClass1, MyClass2\u003e()\n                .AddMapping(MyClass1 =\u003e MyClass1.PropertyToReadFrom, (MyClass2, value) =\u003e MyClass2.PropertyToWriteTo = value)\n                .AddMapping(MyClass1 =\u003e MyClass1.Property1 + MyClass1.Property2, (MyClass1, value) =\u003e MyClass2.ComputedProperty = value)\n                .AddMapping(MyClass1 =\u003e MyClass1.A.B.C.D, (MyClass1, value) =\u003e MyClass2.ProjectionProperty = value)\n                .Build();\n\nThe above code could also be written using the extension method Map:\n\n    MyClass1Object.Map\u003cMyClass1, MyClass2\u003e()\n                    .AddMapping(MyClass1 =\u003e MyClass1.PropertyToReadFrom, (MyClass2, value) =\u003e MyClass2.PropertyToWriteTo = value)\n                    .AddMapping(MyClass1 =\u003e MyClass1.Property1 + MyClass1.Property2, (MyClass1, value) =\u003e MyClass2.ComputedProperty = value)\n                    .AddMapping(MyClass1 =\u003e MyClass1.A.B.C.D, (MyClass1, value) =\u003e MyClass2.ProjectionProperty = value)\n                    .Build();\n\t\t\t\t\t\nYou can also supply your own method for copying the data:\n\n    MyClass1Object.Map\u003cMyClass1, MyClass2\u003e()\n                    .UseMethod(MyCopier)\n                    .Build();\n\nIt's also possible, if you'd prefer, for the system to map everything for you based on the conventions that the system uses:\n\n    DataMapper.AutoMap\u003cMyClass1, MyClass2\u003e();\n\nOr:\n\n    MyClass1Object.AutoMap\u003cMyClass2\u003e();\n\nAnd lastly, you can simply skip the above steps all together and simply start using the library:\n\n    MyClass2 Result = MyClass1Object.To\u003cMyClass2\u003e();\n\nIf you don't set up the mapping beforehand, the library will go through the properties on MyClass1 and map them to properties with the same name on MyClass2. It compares the property names by first looking for exact matches, then it will drop underscores and compare them ignoring case.\n\n## Give Me Speed\n\nThe library is about 34% faster than AutoMapper in more complex scenarios:\n\n``` ini\n\nBenchmarkDotNet=v0.13.0, OS=Windows 10.0.18363.1440 (1909/November2019Update/19H2)\nIntel Core i7-9850H CPU 2.60GHz, 1 CPU, 12 logical and 6 physical cores\n.NET SDK=5.0.203\n  [Host]     : .NET 5.0.6 (5.0.621.22011), X64 RyuJIT\n  DefaultJob : .NET 5.0.6 (5.0.621.22011), X64 RyuJIT\n\n\n```\n|                            Method |      Mean |     Error |    StdDev | Ratio | RatioSD | Rank |\n|---------------------------------- |----------:|----------:|----------:|------:|--------:|-----:|\n|                        AutoMapper | 91.575 ns | 0.9259 ns | 0.8661 ns |  1.34 |    0.02 |    2 |\n|                ObjectCartographer | 68.374 ns | 0.6952 ns | 0.6163 ns |  1.00 |    0.00 |    1 |\n\nAnd about 350% faster when an object is supplied to it and only data copying is required.\n\n``` ini\n\nBenchmarkDotNet=v0.13.0, OS=Windows 10.0.18363.1440 (1909/November2019Update/19H2)\nIntel Core i7-9850H CPU 2.60GHz, 1 CPU, 12 logical and 6 physical cores\n.NET SDK=5.0.203\n  [Host]     : .NET 5.0.6 (5.0.621.22011), X64 RyuJIT\n  DefaultJob : .NET 5.0.6 (5.0.621.22011), X64 RyuJIT\n\n\n```\n|             Method |      Mean |     Error |    StdDev |    Median | Ratio | RatioSD | Rank |\n|------------------- |----------:|----------:|----------:|----------:|------:|--------:|-----:|\n|         AutoMapper | 88.796 ns | 1.4598 ns | 3.2951 ns | 87.404 ns |  3.48 |    0.16 |    2 |\n| ObjectCartographer | 26.804 ns | 0.2989 ns | 0.2650 ns | 26.712 ns |  1.00 |    0.00 |    1 |\n\n## Installation\n\nThe library is available via Nuget with the package name \"ObjectCartographer\". To install it run the following command in the Package Manager Console:\n\nInstall-Package ObjectCartographer\n\nNote that there is a package that adds mapping for ADO.Net specific data types: \"ObjectCartographer.SQL\" so the system can do things like map DbType to SqlDbType along with other functionality.\n\n## FAQ\n\n1. How do I add my own converter to the system?\n\nYou would need to implement the ObjectCartographer.ExpressionBuilder.Interfaces.IConverter interface. There is also the ObjectCartographer.ExpressionBuilder.BaseClasses.ConverterBaseClass abstract class to help with destination object creation/copy constructor discovery which is good in instances where you are mapping more complex objects. For simple data conversions like string to an int, the IConverter interface should be enough.\n\n## Build Process\n\nIn order to build the library you may require the following:\n\n1. Visual Studio 2022\n\nOther than that, just clone the project and you should be able to load the solution and build without too much effort.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacraig%2Fobjectcartographer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacraig%2Fobjectcartographer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacraig%2Fobjectcartographer/lists"}