Service Models
Service models are the request/response objects exchanged between the client and Serenity service endpoints. Every endpoint action takes a request object (derived from ServiceRequest) and returns a response object (derived from ServiceResponse). The same shapes are used by the client-side proxies generated by servertypings, so the TypeScript ListRequest, SaveRequest, etc. mirror these classes.
Base Classes
ServiceRequest
ServiceRequest is the base class for all request objects. It has a single member:
public class ServiceRequest
{
public Dictionary<string, object> CustomData { get; set; }
}
CustomData is a catch-all dictionary for passing extra data. The docs recommend subclassing the request type instead when you need extra fields, and reserving CustomData for limited cases where subclassing isn't feasible.
ServiceResponse
ServiceResponse is the base class for all response objects:
public class ServiceResponse
{
public ServiceError Error { get; set; }
public Dictionary<string, object> CustomData { get; set; }
}
Error is set when the request fails — see Validation for how a ValidationError becomes a ServiceError with HTTP 400.
Request Models
| Request | Base | Purpose | Detailed in |
|---|---|---|---|
SaveRequest<TEntity> |
ServiceRequest, ISaveRequest |
Create/update payload (EntityId, Entity, Localizations) |
Save Request Handler |
ListRequest |
ServiceRequest, IIncludeExcludeColumns |
Grid/query parameters (paging, sort, filters, column selection) | List Request Handler |
RetrieveRequest |
ServiceRequest, IIncludeExcludeColumns |
Single-record fetch (EntityId, ColumnSelection) |
Retrieve Request Handler |
DeleteRequest |
ServiceRequest |
Delete by ID (EntityId) |
Delete Request Handler |
UndeleteRequest |
ServiceRequest |
Undelete by ID (EntityId) |
Undelete Request Handler |
Response Models
| Response | Base | Members | Detailed in |
|---|---|---|---|
SaveResponse |
ServiceResponse |
EntityId |
Save Request Handler |
ListResponse<T> |
ServiceResponse, IListResponse |
Entities, Values, TotalCount, Skip, Take |
List Request Handler |
RetrieveResponse<T> |
ServiceResponse, IRetrieveResponse |
Entity, Localizations |
Retrieve Request Handler |
DeleteResponse |
ServiceResponse |
WasAlreadyDeleted |
Delete Request Handler |
UndeleteResponse |
ServiceResponse |
WasNotDeleted |
Undelete Request Handler |
Non-Generic Access Interfaces
The generic models (SaveRequest<TEntity>, ListResponse<T>, RetrieveResponse<T>) are awkward to use when you don't know the entity type at compile time. Serenity provides non-generic interfaces for exactly this:
| Interface | Gives access to | Used by |
|---|---|---|
ISaveRequest |
EntityId, Entity, Localizations (as object/IDictionary) |
ISaveRequestProcessor, behaviors |
IListResponse |
Entities (as IList), TotalCount, Skip, Take |
IListRequestHandler, behaviors |
IRetrieveResponse |
Entity (as object), Localizations |
IRetrieveRequestHandler, behaviors |
For example, IListRequestHandler.Response is typed as IListResponse, so a list behavior can read TotalCount or enumerate Entities without knowing the row type.
IIncludeExcludeColumns
IIncludeExcludeColumns is implemented by ListRequest and RetrieveRequest. It exposes the IncludeColumns / ExcludeColumns sets that control which columns are selected — see List Request Handler for how they interact with ColumnSelection and SelectLevel.
ServiceError and SortBy
ServiceError— the error object returned inServiceResponse.Error(Code,Arguments,Message,Details,ErrorId). See Validation.SortBy— a sort descriptor (Field,Descending) used byListRequest.Sort. See List Request Handler.
Client-Side Typings
The servertypings command generates TypeScript equivalents of these models (e.g. ListRequest, SaveRequest<TRow>, ListResponse<TRow>) into Imports/ServerTypings, so the client-side service proxies and grids use the same shapes. See Sergen Commands.