Repository navigation
Expressions Property Access
Navigate through object relationships with simple, nested, and null-safe property access.
Access simple properties directly:
Name
Email
Status
Use ? to return null instead of throwing an exception when the property is null:
Country?
Address?.City
Access nested properties through multiple levels using dot notation:
Country.Province.City.Name
Order.Customer.Address.ZipCode
Combine null-safe operator with navigation for safe deep access:
Country?.Province?.City.Name
Order?.Customer?.Email
// Distributed keys
public sealed class UserDistributedKey : IDistributedKey;
public sealed class ProvinceDistributedKey : IDistributedKey;
// Entity configs (data-provider side)
public class UserConfig : EntityConfigureOf<User>
{
protected override void Configure()
{
Id(x => x.Id);
DefaultProperty(x => x.Name);
UseDistributedKey<UserDistributedKey>();
}
}
public class ProvinceConfig : EntityConfigureOf<Province>
{
protected override void Configure()
{
Id(x => x.Id);
DefaultProperty(x => x.Name);
UseDistributedKey<ProvinceDistributedKey>();
}
}
// DTO and profile - Navigate through relationships
public class UserLocationResponse
{
public string UserId { get; set; }
public string UserName { get; set; }
public string ProvinceName { get; set; }
public string CountryName { get; set; }
public string? SafeCountryName { get; set; }
}
public class UserLocationResponseProfile : ProfileOf<UserLocationResponse>
{
protected override void Configure()
{
UseDistributedKey<UserDistributedKey>()
.Of(x => x.UserId)
.For(x => x.UserName) // default property
.For(x => x.ProvinceName, "Province.Name") // one-level navigation
.For(x => x.CountryName, "Province.Country.Name") // multi-level navigation
.For(x => x.SafeCountryName, "Province?.Country?.Name"); // null-safe
}
}When you use navigation expressions, FxMap intelligently handles the data fetching:
-
Single Service: Uses optimized database queries (e.g., SQL JOINs with EF Core)
-
Microservices: Automatically makes transport calls to fetch related data
-
Batching: Groups multiple queries for optimal performance
- The
?operator can be used on any segment in a navigation chain - Returns
nullinstead of throwingNullReferenceException - If any relationship is null, the target property will remain its default value
Source: https://fxmapper.net/docs/expressions/navigation/ — the website is always the most up to date version.
Introduction
Getting Started
Configuration
- Service Registration
- Entities & Profiles
- Handlers
- Pipelines
- Strongly Typed IDs
- Error Handling
- Retry Policy
- Supervisor
- Telemetry
- Kestrel (HTTP/2)
- Analyzers
Expressions
- Overview
- Property Access
- Filters, Sorting & Paging
- Functions
- Aggregations
- Projections
- Coalesce & Ternary
- GroupBy
Data Providers
Transports
Integrations
Quality
AI Assistants
Migration
Release Notes