OfX 9.0.0
dotnet add package OfX --version 9.0.0
NuGet\Install-Package OfX -Version 9.0.0
<PackageReference Include="OfX" Version="9.0.0" />
<PackageVersion Include="OfX" Version="9.0.0" />
<PackageReference Include="OfX" />
paket add OfX --version 9.0.0
#r "nuget: OfX, 9.0.0"
#:package OfX@9.0.0
#addin nuget:?package=OfX&version=9.0.0
#tool nuget:?package=OfX&version=9.0.0
OfX
public string XId { get; set; }
[XOf(nameof(XId))] public string X { get; set; }
OfX is an open-source library focused on Attribute-based data mapping. It streamlines data handling across services, reduces boilerplate code, and improves maintainability.
Full Documentation | Getting Started |Expression Language
All OfX* packages need to have the same version.
Quick Start
dotnet add package OfX
// 1. Configure OfX
builder.Services.AddOfX(cfg =>
{
cfg.AddAttributesContainNamespaces(typeof(UserOfAttribute).Namespace!);
cfg.AddModelConfigurationsFromNamespaceContaining<SomeModelAssemblyMarker>();
});
// 2. Define a custom OfXAttribute
public sealed class UserOfAttribute(string propertyName) : OfXAttribute(propertyName);
// 3. Configure the model
[OfXConfigFor<UserOfAttribute>(nameof(Id), nameof(Name))]
public sealed class User
{
public string Id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
}
// 4. Use attributes in your DTOs
public sealed class SomeDataResponse
{
public string UserId { get; set; }
[UserOf(nameof(UserId))]
public string UserName { get; set; }
[UserOf(nameof(UserId), Expression = "Email")]
public string UserEmail { get; set; }
}
Key Features
- Attribute-based Mapping: Declarative data fetching using custom attributes
- 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
- GraphQL Integration: Seamless integration with HotChocolate
Expression Examples
// Simple property access
[UserOf(nameof(UserId), Expression = "Email")]
public string UserEmail { get; set; }
// Navigation properties
[ProvinceOf(nameof(ProvinceId), Expression = "Country.Name")]
public string CountryName { get; set; }
// Filtering
[UserOf(nameof(UserId), Expression = "Orders(Status = 'Done')")]
public List<OrderDTO> CompletedOrders { get; set; }
// Aggregation
[UserOf(nameof(UserId), Expression = "Orders:sum(Total)")]
public decimal TotalSpent { get; set; }
// Projection
[UserOf(nameof(UserId), Expression = "{Id, Name, Address.City as CityName}")]
public UserInfo UserDetails { get; set; }
// GroupBy
[UserOf(nameof(UserId), Expression = "Orders:groupBy(Status).{Status, :count as Count}")]
public List<OrderSummary> OrdersByStatus { get; set; }
For complete expression syntax including filters, indexers, functions, aggregations, boolean functions, coalesce, ternary operators, and more, visit Expression Documentation.
Packages
| Package | Description | .NET |
|---|---|---|
| Core | ||
| OfX | Core library | 8.0, 9.0 |
| Data Providers | ||
| OfX-EFCore | Entity Framework Core provider | 8.0, 9.0 |
| OfX-MongoDb | MongoDB provider | 8.0, 9.0 |
| Integrations | ||
| OfX-HotChocolate | HotChocolate GraphQL integration | 8.0, 9.0 |
| Transports | ||
| OfX-gRPC | gRPC transport | 8.0, 9.0 |
| OfX-Nats | NATS transport | 8.0, 9.0 |
| OfX-RabbitMq | RabbitMQ transport | 8.0, 9.0 |
| OfX-Kafka | Kafka transport | 8.0, 9.0 |
| OfX-Azure.ServiceBus | Azure Service Bus transport | 8.0, 9.0 |
Documentation
Visit ofxmapper.net for:
- Getting Started Guide
- Configuration Options
- Expression Language Reference
- Data Provider Setup
- Transport Configuration
- API Reference
Contributing
Contributions are welcome! Please visit our GitHub repository to:
- Report issues
- Submit pull requests
- Request features
License
This project is licensed under the Apache-2.0 license.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging (>= 8.0.0)
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging (>= 8.0.0)
-
net9.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging (>= 8.0.0)
NuGet packages (10)
Showing the top 5 NuGet packages that depend on OfX:
| Package | Downloads |
|---|---|
|
OfX-EFCore
OfX extension. Use EntityFramework as Data Querying |
|
|
OfX-Nats
Nats.io extension. Use Nats as Data transporting |
|
|
OfX-gRPC
OfX extension. Use gRPC as Data transporting |
|
|
OfX-RabbitMq
OfX-RabbitMq extension. Use RabbitMq as Data transporting |
|
|
OfX-Kafka
OfX-Kafka extension. Use Kafka as Data transporting |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 9.0.0 | 142 | 2/11/2026 | |
| 8.3.0 | 223 | 2/9/2026 | |
| 8.2.6 | 245 | 1/28/2026 | |
| 8.2.5 | 219 | 1/24/2026 | |
| 8.2.4 | 838 | 1/19/2026 | |
| 8.2.3 | 219 | 1/18/2026 | |
| 8.2.2 | 329 | 1/18/2026 | |
| 8.2.1 | 226 | 1/17/2026 | |
| 8.2.0 | 211 | 1/17/2026 | |
| 8.1.2 | 360 | 1/13/2026 | |
| 8.1.1 | 216 | 1/13/2026 | |
| 8.1.0 | 220 | 1/11/2026 | |
| 8.0.0 | 376 | 1/3/2026 | |
| 7.2.2 | 486 | 12/18/2025 | |
| 7.2.1 | 760 | 12/1/2025 | |
| 7.2.0 | 569 | 11/18/2025 | |
| 7.2.0-preview | 553 | 11/18/2025 | |
| 7.1.10 | 344 | 10/20/2025 | |
| 7.1.9 | 323 | 10/17/2025 | |
| 7.1.8 | 331 | 10/15/2025 |