Notification Queries
Summary
Reads are EF Core LINQ queries written directly in endpoint handlers and application services against NotificationDbContext. There is no formal query object model, query handler or read-model projection layer. Read queries consistently use AsNoTracking.
Verified read operations
| Query | Where implemented | Notes (verified) |
|---|---|---|
| Recipient inbox | GET /notifications/my | Filters in-app messages for a recipient reference and tenant; optional unread-only; take clamped to 1–500 |
| Single message | GET /notifications/{id} | Returns the message or not-found |
| Delivery attempts | GET /notifications/{id}/attempts | Ordered by attempt number |
| Failed messages | GET /notifications/failed | Status == Failed, most recent first, take clamped |
| Processed-event lookup | GET /notifications/processed/{eventId} | Idempotency-ledger read |
| Audit trail | GET /notifications/audit | Filter by event, correlation or message; take clamped to 1–1000 |
| Statistics | GET /notifications/stats | Counts of templates, recipients, messages, sent/failed/read, processed events and attempts |
| Template list | GET /notification-templates | Optional tenant/key/channel/active filters |
| Template resolution | TemplateEngine.ResolveAndRenderAsync | Highest active version, tenant over global |
| Preference decision | PreferenceEvaluator.IsEnabledAsync | Loads applicable rows; exact event wins over wildcard |
Read model
Queries project into anonymous objects or return entities directly. Paging is bounded with Math.Clamp. Ordering is explicit (for example, inbox by CreatedOnUtc descending). Tenant scoping is applied per query via the supplied tenantId.
Verified absence
There are no *Query classes, no IQueryHandler, no CQRS read side and no materialized read models. Queries execute against the live write schema.
Requires Confirmation
Index coverage for large-volume audit and message queries in production requires confirmation; the DbContext defines targeted indexes but real data volumes are unknown.
Source References
microservices/src/notification-service/Api/NotificationEndpoints.csmicroservices/src/notification-service/Application/TemplateEngine.csmicroservices/src/notification-service/Application/PreferenceEvaluator.cs
Related Articles
See Also
Keywords
Queries, read operations, inbox, audit, statistics, verified absence.
Revision Information
- Status: Draft
- Last reviewed: 2026-07-21
- Next review: 2026-10-21