Getting Started
Installation
Section titled “Installation”TacoMapper can be installed via NuGet Package Manager or by adding a project reference.
Via NuGet
Section titled “Via NuGet”dotnet add package TacoMapper
Via Project Reference
Section titled “Via Project Reference”If you’re building from source or using the library locally:
dotnet add reference path/to/lib/TacoMapper.csproj
Basic Usage
Section titled “Basic Usage”Simple Auto-Mapping
Section titled “Simple Auto-Mapping”The simplest way to use TacoMapper is with auto-mapping for objects with matching property names and types:
using TacoMapper.Core;
// Assuming Person and PersonDto have matching propertiesvar person = new Person{ Id = 1, FirstName = "John", LastName = "Doe"};
var personDto = ObjectMapper.Map<Person, PersonDto>(person);
Fluent API Configuration
Section titled “Fluent API Configuration”For more control over the mapping process, use the fluent API:
var mapper = ObjectMapper.Create<Person, PersonDto>() .Map(dest => dest.Id, src => src.Id) .Map(dest => dest.Email, src => src.Email) .Combine(dest => dest.FullName, src => $"{src.FirstName} {src.LastName}");
var result = mapper.MapFrom(person);
Working with Collections
Section titled “Working with Collections”TacoMapper supports mapping collections efficiently:
var people = new List<Person> { /* your data */ };
// Using a configured mappervar mapper = ObjectMapper.Create<Person, PersonDto>() .Map(dest => dest.Id, src => src.Id) .Combine(dest => dest.FullName, src => $"{src.FirstName} {src.LastName}");
var results = mapper.MapFrom(people);
// Or simple auto-mapping for collectionsvar simpleResults = ObjectMapper.Map<Person, PersonDto>(people);
Requirements
Section titled “Requirements”- .NET 8.0 or later
- C# 12.0 language features
Next Steps
Section titled “Next Steps”- Learn about advanced mapping techniques
- Explore conditional mapping
- Check the API reference