{"id":21140405,"url":"https://github.com/rem0o/dynamicmapper","last_synced_at":"2025-07-09T04:31:22.339Z","repository":{"id":41178135,"uuid":"153949250","full_name":"Rem0o/DynamicMapper","owner":"Rem0o","description":"Dynamic POCO mappers using the Roselyn Compiler.","archived":false,"fork":false,"pushed_at":"2019-03-27T01:46:53.000Z","size":16,"stargazers_count":8,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-05-02T00:48:54.216Z","etag":null,"topics":["csharp-script","dotnet-standard","orm","sql"],"latest_commit_sha":null,"homepage":"","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/Rem0o.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}},"created_at":"2018-10-20T21:18:31.000Z","updated_at":"2024-05-01T12:35:24.000Z","dependencies_parsed_at":"2022-08-18T23:10:35.463Z","dependency_job_id":null,"html_url":"https://github.com/Rem0o/DynamicMapper","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rem0o%2FDynamicMapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rem0o%2FDynamicMapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rem0o%2FDynamicMapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rem0o%2FDynamicMapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rem0o","download_url":"https://codeload.github.com/Rem0o/DynamicMapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225482712,"owners_count":17481235,"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":["csharp-script","dotnet-standard","orm","sql"],"created_at":"2024-11-20T07:15:29.642Z","updated_at":"2024-11-20T07:15:30.303Z","avatar_url":"https://github.com/Rem0o.png","language":"C#","readme":"# DynamicMapper [![Build Status](https://travis-ci.com/Rem0o/DynamicMapper.svg?branch=master)](https://travis-ci.com/Rem0o/DynamicMapper)\n\nCreate all your POCO mappers dynamically from your POCO types directly using static reflection and the Roselyn compiler.\n\nThe mappers can be compiled once dynamically at startup. Once created, the mappers are then cached. Each mapper should give similar performance to manual object mapping directly from your source object.\n\n### Code exemple\n\n```c#\n// Compiles mappers for all classes under a specific namespace at startup to map from a IDataReader source object;\nvar mapperContainer = new DynamicMapperContainer\u003cIDataReader\u003e((reader, propertyName) =\u003e reader[propertyName])\n    .CompileMappers(this.GetType().Assembly, t =\u003e t.Namespace == typeof(MyPocoClass).Namespace);\n// (...)\n\n// If the type was not included during the container construction, the container will try to compile the mapper\n// for the given class dynamically and cache it for later use. \nmapperContainer.GetMapper\u003cMyPocoClass\u003e(out Action\u003cIDataReader, MyPocoClass\u003e mapper);\n\n// use mapper here ...\nusing (var connection = new SqlConnection(\"some connection string\"))\n{\n    SqlCommand command = new SqlCommand(\"SELECT * FROM SomeTable\", connection);\n    connection.Open();\n    \n    SqlDataReader reader = command.ExecuteReader();\n    \n    while (reader.Read())\n    {\n        var poco = new MyPocoClass();\n        mapper(reader, poco);\n        // poco was mapped!\n    }\n    \n    reader.Close();\n}\n\n\n```\n\n### Some performance testing\nHere are some basic performance testing comparing manual mapping, DynamicMapper and Dapper. The results are for demonstration purpose only and may not reflect your personal results.\n\nTest conditions:\n\n- Mapping a simple POCO with 7 properties\n- 100 000 itterations\n- Manual mapping and DynamicMapper both use a basic SqlConnection/SqlCommand/SqlDataReader implementation like the code exemple above.\n- Dapper uses the IDbConnection.Query\u003cT\u003e extension method.\n\nResults:\n\n| Mapper         | Time (ms) |\n| -------------- | --------- |\n| DynamicMapper  | 917       |\n| Manual mapping | 669       |\n| Dapper         | 1061      |\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frem0o%2Fdynamicmapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frem0o%2Fdynamicmapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frem0o%2Fdynamicmapper/lists"}