SegmentResult<T>
SegmentResult<T> is the return shape of ToListAsync<T>(Segment). It inherits every property from FilterResult<T> — there are no additional members. The separate type exists only to distinguish results that came from a segment query (Union / Intersect / Except, combined into one query) from those that came from a plain filter.
Inherited properties
| Property | Type | Description |
|---|---|---|
PageNumber | int | Current page (0 when no pagination). |
PageSize | int | Page size (0 when no pagination). |
PageCount | int | Total pages. 1 when no Page was sent (0 with no rows). |
TotalCount | int | Total matching records (across all combined sets). |
Data | List<T> | The requested page of the combined rows, each row once. With Selects, unselected members hold their defaults. |
QueryString | string? | Always null here: the Segment overload takes no getQueryString argument and never fills this in. |
Policy | PolicyTrace? | What the policy layer did to this query. null unless the query went through ApplyPolicy. A guarded query sets it as DwPolicyOptions.IncludeTraceInResult decides: by default it is present under the convenience tier and null under the strict tier (since 3.1.0 — see breaking changes). The trace is always on PolicyQueryable<T>.LastTrace. |
Changed in 3.1.0: the database combines the sets
TotalCount counts rows, each once, whether the query tracks, runs AsNoTracking() or carries Selects. The sets used to be loaded one query each and combined in memory by object reference, so an untracked or projected segment counted a row once per set in a Union, found nothing to Intersect and nothing to Except. Data is now the one page the database returns.Changed in 3.1.0: an unpaged segment reports one page
Send a
Page and PageCount is Ceiling(TotalCount / PageSize). Send none and it is 1 — the one page the whole result occupies — or 0 when nothing matched, the same answer a FilterResult<T> gives. Before 3.1.0 an unpaged segment with condition sets left PageCount at 0 beside a full page of rows, while the same request as a filter reported one page per row. PageNumber and PageSize still report 0 when no page was sent. The exception is a guarded query when the deployment sets DwCaps.DefaultPageSize, or the context declares a purpose with a default page of its own (3.4.0): the query is given page 1 at that size, and reports it.Note
Because
SegmentResult<T> inherits FilterResult<T>, any helper or extension you write against the base type works for both.C# usage
SegmentResult<Customer> result = await dbContext.Customers.ToListAsync(segment);
Console.WriteLine($"page {result.PageNumber} of {result.PageCount}");
Console.WriteLine($"{result.TotalCount} total matches");
foreach (var customer in result.Data)
{
Console.WriteLine($"- {customer.Name}");
}JSON response example
{
"pageNumber": 1,
"pageSize": 50,
"pageCount": 3,
"totalCount": 124,
"data": [
{ "id": 7, "name": "John Doe" },
{ "id": 12, "name": "Aisha Khan" }
],
"queryString": null,
"policy": null
}See also
- Segment →
- FilterResult<T> → the base type.
- ToListAsync<T>(Segment) →