Repository navigation
Expressions Functions
Transform data with string, date/time, math, and collection functions using the :functionName syntax.
| Function | Syntax | Example | Result |
|---|---|---|---|
| Upper | :upper |
Name:upper |
"JOHN" |
| Lower | :lower |
Name:lower |
"john" |
| Trim | :trim |
Name:trim |
"John" (whitespace removed) |
| Substring | :substring(start, length?) |
Name:substring(0, 3) |
"Joh" |
| Replace | :replace(old, new) |
Name:replace('o', 'a') |
"Jahn" |
| Concat | :concat(values...) |
Name:concat(' ', LastName) |
"John Doe" |
| Split | :split(separator) |
Tags:split(',') |
["a", "b", "c"] |
| Function | Syntax | Example | Result |
|---|---|---|---|
| Year | :year |
CreatedAt:year |
2024 |
| Month | :month |
CreatedAt:month |
12 (1-12) |
| Day | :day |
CreatedAt:day |
25 (1-31) |
| Hour | :hour |
CreatedAt:hour |
14 (0-23) |
| Minute | :minute |
CreatedAt:minute |
30 (0-59) |
| Second | :second |
CreatedAt:second |
45 (0-59) |
| Day of Week | :dayOfWeek |
CreatedAt:dayOfWeek |
1 (Sun=0...Sat=6) |
| Days Ago | :daysAgo |
CreatedAt:daysAgo |
5 (days from date to today) |
| Format | :format(pattern) |
CreatedAt:format('yyyy-MM-dd') |
"2024-12-25" |
| Function | Syntax | Example | Description |
|---|---|---|---|
| Round | :round(decimals?) |
Price:round(2) |
Round to 2 decimal places |
| Floor | :floor |
Price:floor |
Round down |
| Ceiling | :ceil |
Price:ceil |
Round up |
| Absolute | :abs |
Balance:abs |
Absolute value |
| Add | :add(operand) |
Price:add(Tax) |
Addition |
| Subtract | :subtract(operand) |
Price:subtract(10) |
Subtraction |
| Multiply | :multiply(operand) |
Price:multiply(Quantity) |
Multiplication |
| Divide | :divide(operand) |
Total:divide(2) |
Division |
| Modulo | :mod(divisor) |
Value:mod(3) |
Modulo operation |
| Power | :pow(exponent) |
Value:pow(2) |
Exponentiation |
Note: Operand can be a number literal or property reference.
| Function | Syntax | Example | Description |
|---|---|---|---|
| Where | :where(condition) |
Orders:where(Status = 'Done') |
Keep the items that match the condition |
| OrderBy | `:orderBy(Key [asc | desc], ...)` | Orders:orderBy(Date desc) |
| Offset | :offset(n) |
Orders:offset(5) |
Skip the first n items |
| Limit | :limit(n) |
Orders:limit(10) |
Keep at most n items |
| First | :first |
Orders:orderBy(Date):first |
The first item, or null if the collection is empty |
| Last | :last |
Orders:orderBy(Date):last |
The last item, or null if the collection is empty |
| Distinct | :distinct(property) |
Items:distinct(Name) |
Get unique property values |
| Count | :count |
Items:count |
Count items in collection |
Filtering, sorting and paging have their own page with the details and the limits: Filters, Sorting & Paging.
Functions can be chained together as long as the output type matches the input type:
# String chaining
Name:trim:upper:substring(0, 3) # " john " → "JOH"
# Math chaining
Price:add(Tax):round(2) # (Price + Tax) rounded to 2 decimals
# Date + Math
CreatedAt:year:add(1) # Year + 1
# Collection chaining
Items:distinct(Category):count # Count unique categories
// The service that asks for the data
public class OrderResponse
{
public string OrderId { get; set; }
public string CustomerNameUpper { get; set; }
public string CustomerNameClean { get; set; }
public int OrderYear { get; set; }
public string FormattedDate { get; set; }
public int DaysOld { get; set; }
public decimal RoundedTotal { get; set; }
public decimal CalculatedTotal { get; set; }
public int UniqueCategories { get; set; }
}
public class OrderResponseProfile : ProfileOf<OrderResponse>
{
protected override void Configure() =>
UseDistributedKey<OrderDistributedKey>()
.Of(x => x.OrderId)
// String functions
.For(x => x.CustomerNameUpper, "Customer.Name:upper")
.For(x => x.CustomerNameClean, "Customer.Name:trim:lower")
// Date functions
.For(x => x.OrderYear, "CreatedAt:year")
.For(x => x.FormattedDate, "CreatedAt:format('yyyy-MM-dd')")
.For(x => x.DaysOld, "CreatedAt:daysAgo")
// Math functions
.For(x => x.RoundedTotal, "Total:round(2)")
.For(x => x.CalculatedTotal, "Price:multiply(Quantity):add(Tax)")
// Collection functions
.For(x => x.UniqueCategories, "Items:distinct(Category):count");
}Each .For(...) takes the property to fill and the expression to run on the entity that owns the data. The owning service only needs the usual entity configuration.
Functions can be used within filter conditions:
# Orders with more than 5 items
Orders:where(Items:count > 5)
# Case-insensitive comparison
Users:where(Name:lower = 'john')
# Filter by year
Orders:where(CreatedAt:year = 2024)
# Filter by days ago
Orders:where(CreatedAt:daysAgo < 7)
Source: https://fxmapper.net/docs/expressions/functions/ — 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