Skip to content
quyvu edited this page Oct 13, 2026 · 3 revisions

What is FxMap?

FxMap is an open-source framework that focuses on FluentAPI-based distributed data mapping. It streamlines data handling across services, reduces boilerplate code, and improves maintainability in microservice architectures.

The Problem

In microservice architectures, you often need to fetch related data from different services. Traditionally, this requires writing repetitive mapping code for each property.

// Without FxMap - Manual mapping required
public class OrderResponse
{
    public string UserId { get; set; }
    public string UserName { get; set; } // Need to manually fetch
    public string UserEmail { get; set; } // Need to manually fetch
}
 
// Somewhere in your code...
var user = await _userService.GetUserAsync(order.UserId);
orderResponse.UserName = user.Name;
orderResponse.UserEmail = user.Email;

The FxMap Solution

With FxMap, you define entity configs and DTO profiles using FluentAPI, and the framework automatically handles all the data fetching and mapping for you.

// With FxMap - Declare once, map automatically
public class OrderResponseProfile : ProfileOf<OrderResponse>
{
    protected override void Configure()
    {
        UseDistributedKey<UserDistributedKey>()
            .Of(x => x.UserId)
            .For(x => x.UserName)
            .For(x => x.UserEmail, "Email");
    }
}
 
// That's it! FxMap handles everything
var mapper = provider.GetService<IDistributedMapper>();
await mapper.MapDataAsync(orderResponse);
// UserName and UserEmail are now populated!

90% Less Code

FxMap eliminates the need for manual mapping logic, freeing developers to focus on core functionality rather than data plumbing.

How It Works

1

Define Distributed Key

Define a distributed key — the shared contract between entity config and DTO profile.

public sealed class UserDistributedKey : IDistributedKey;

2

Configure Models

Use EntityConfigureOf<T> to expose entity data, and ProfileOf<T> to declare what to map.

public class UserConfig : EntityConfigureOf<User>
{
    protected override void Configure()
    {
        Id(x => x.Id);
        DefaultProperty(x => x.Name);
        UseDistributedKey<UserDistributedKey>();
    }
}

3

Use in DTOs

Declare which properties to auto-populate using ProfileOf.

public class OrderResponseProfile : ProfileOf<OrderResponse>
{
    protected override void Configure()
    {
        UseDistributedKey<UserDistributedKey>()
            .Of(x => x.UserId)
            .For(x => x.UserName);
    }
}

Key Benefits

Performance

Compiled expressions are 10x faster than reflection. Zero runtime overhead with compile-time expression trees.

Less Boilerplate

Reduce mapping code by 90%. Configure with FluentAPI — no repetitive mapping logic required.

Transport Agnostic

Works seamlessly with RabbitMQ, NATS, Kafka, gRPC, Azure Service Bus, and AWS SQS. Switch transports without code changes.

Database Ready

Built-in support for Entity Framework Core and MongoDB. Query across microservices with expression-based syntax.

Important

All FxMap.* packages need to have the same version to ensure compatibility.

Perfect For

Microservices Architectures

Simplify data aggregation across multiple services without writing custom mapping code for each endpoint.

Event-Driven Systems

Automatically enrich events with data from other services as they flow through your message bus.

API Gateways

Compose rich response DTOs by automatically fetching related data from backend services.

GraphQL APIs

Seamlessly integrate with HotChocolate to resolve nested fields across service boundaries.


Source: https://fxmapper.net/docs/ — the website is always the most up to date version.

Clone this wiki locally