Effective distributed data mapping!
public string UserId { get; set; }
public string UserName { get; set; }
public string UserEmail { get; set; }FxMap is an open-source library focused on FluentAPI-based data mapping. It streamlines data handling across services, reduces boilerplate code, and improves maintainability.
Full Documentation | Getting Started |Expression Language
Warning
All FxMap.* packages need to have the same version.
dotnet add package FxMap// 1. Configure FxMap
builder.Services.AddFxMap(cfg =>
{
cfg.AddEntitiesFromAssemblyContaining<SomeEntityAssemblyMarker>();
cfg.AddProfilesFromAssemblyContaining<SomeProfileAssemblyMarker>();
});
// 2. Define a distributed key
public sealed class UserDistributedKey : IDistributedKey;
// 3. Configure the entity with FluentAPI
public class UserConfig : EntityConfigureOf<User>
{
protected override void Configure()
{
Id(x => x.Id);
DefaultProperty(x => x.Name);
UseDistributedKey<UserDistributedKey>(); // Or you want to absolute lose coupling, you can use: UseDistributedKey("UserDistributedKey")
ExposedName(x => x.Email, "UserEmail");
}
}
// 4. Define a profile for your DTO
public class UserResponseProfile : ProfileOf<UserResponse>
{
protected override void Configure()
{
UseDistributedKey<UserDistributedKey>() // Or you want to absolute lose coupling, you can use: UseDistributedKey("UserDistributedKey")
.Of(x => x.UserId)
.For(x => x.UserName)
.For(x => x.UserEmail, "Email");
}
}- FluentAPI-based Mapping: Declarative data fetching using
ProfileOf<T>andEntityConfigureOf<T> - Powerful Expression Language: SQL-like DSL for complex queries, filtering, aggregation, and projections
- Multiple Data Providers: Support for EF Core, MongoDB, and more
- Multiple Transports: gRPC, NATS, RabbitMQ, Kafka, Azure Service Bus, Amazon SQS
- GraphQL Integration: Seamless integration with HotChocolate
public class UserResponseProfile : ProfileOf<UserResponse>
{
protected override void Configure()
{
UseDistributedKey<UserOfAttribute>()
.Of(x => x.UserId)
// Simple property access
.For(x => x.UserEmail, "Email")
// Navigation properties
.For(x => x.CountryName, "Country.Name")
// Filtering
.For(x => x.CompletedOrders, "Orders(Status = 'Done')")
// Aggregation
.For(x => x.TotalSpent, "Orders:sum(Total)")
// Projection
.For(x => x.UserDetails, "{Id, Name, Address.City as CityName}")
// GroupBy
.For(x => x.OrdersByStatus, "Orders:groupBy(Status).{Status, :count as Count}");
}
}For complete expression syntax including filters, indexers, functions, aggregations, boolean functions, coalesce, ternary operators, and more, visit Expression Documentation.
| Package | Description | .NET |
|---|---|---|
| Core | ||
| FxMap | Core library | 8.0, 9.0, 10.0 |
| Data Providers | ||
| FxMap.EntityFrameworkCore | Entity Framework Core provider | 8.0, 9.0, 10.0 |
| FxMap.MongoDb | MongoDB provider | 8.0, 9.0, 10.0 |
| Integrations | ||
| FxMap.HotChocolate | HotChocolate GraphQL integration | 8.0, 9.0, 10.0 |
| Transports | ||
| FxMap.Grpc | gRPC transport | 8.0, 9.0, 10.0 |
| FxMap.Nats | NATS transport | 8.0, 9.0, 10.0 |
| FxMap.RabbitMq | RabbitMQ transport | 8.0, 9.0, 10.0 |
| FxMap.Kafka | Kafka transport | 8.0, 9.0, 10.0 |
| FxMap.Azure.ServiceBus | Azure Service Bus transport | 8.0, 9.0, 10.0 |
| FxMap.Aws.Sqs | Amazon SQS transport | 8.0, 9.0, 10.0 |
| Tooling | ||
| FxMap.Analyzers | Roslyn analyzers | 8.0, 9.0, 10.0 |
Visit fxmapmapper.net for:
- Getting Started Guide
- Configuration Options
- Expression Language Reference
- Data Provider Setup
- Transport Configuration
- API Reference
Contributions are welcome! Please visit our GitHub repository to:
- Report issues
- Submit pull requests
- Request features
This project is licensed under the Apache-2.0 license.