SaveRequestHandler<TRow,TSaveRequest,TSaveResponse> class

namespace: Serenity.Services   assemblySerenity.Net.Services

Generic base class for save request handlers

public class SaveRequestHandler<TRow, TSaveRequest, TSaveResponse> : 
    ISaveHandler<TRow, TSaveRequest, TSaveResponse>, ISaveRequestProcessor
    where TRow : class, IRow, IIdRow, new()
    where TSaveRequest : SaveRequest<TRow>, new()
    where TSaveResponse : SaveResponse, new()
parameter description
TRow Entity type
TSaveRequest Save request type
TSaveResponse Save response type

Public Members

name description
SaveRequestHandler(…) Creates a new instance of the class
Cache { get; } Gets the two level cache from the request context
Connection { get; } Gets connection
Context { get; } Gets the request context
IsCreate { get; } Returns true if this is a Create operation
IsUpdate { get; } Returns true if this is an Update operation
Localizer { get; } Gets localizer from the request context
Old { get; protected set; } The old entity for update
Permissions { get; } Gets permission service from the request context
Request { get; protected set; } Request object
Response { get; protected set; } Response object
Row { get; protected set; } The inserted entity for Create and new entity for Update
StateBag { get; } A state bag for behaviors to preserve state among their methods. It will be cleared before each request, e.g. Process call.
UnitOfWork { get; protected set; } Gets the current unit of work
User { get; } Gets current user from the request context
Create(…)
Process(…) Processes the save request. This is the entry point for the handler.
Update(…)

Protected Members

name description
behaviors- Lazy list of behaviors that is activated for this request
virtual AfterSave() Called after executing the insert/update statement
virtual BeforeSave() Called before executing the insert/update statement
virtual ClearNonTableAssignments() Clears assignment for fields that are marked as non table field, e.g. fields that are not mapped, view, expression etc.
virtual CustomValidate(…) Calls custom validator
virtual ExecuteSave() Executes the actual SQL save operation
virtual GetBehaviors() Gets the list of save behaviors
virtual GetDisplayOrderFilter() Gets the display order filter for current group, if the entity implements IDisplayOrderRow interface
virtual GetEditableFields(…) Gets the list of editable fields. These are fields that have Insertable (if Create), or Updatable (if Update) flags, and have the insert or update permission based on the type of the current operation.
virtual GetRequiredFields(…) Gets the list of required fields based on editable list, and NotNull
virtual HandleDisplayOrder(…) Handles display order field calculation before and after save
virtual HandleNonEditable(…) Handles assignment to a non-editable field. If the field did not change in an update operation, it will be ignored by clearing the assignment. For non-table fields it will also be ignored.
virtual InvalidateCacheOnCommit() Attaches an handler to unit of work's OnCommit event to invalidate the cache items related to this row's cache group
virtual InvokeSaveAction(…) Invokes the passed save action method
virtual LoadOldEntity() Loads the old entity for an update operation
virtual OnReturn() Called just before the response is returned
virtual PerformAuditing() Performs auditing
virtual PrepareQuery() Prepares the query for selecting old record in an update operation
virtual SetDefaultValue(…) Sets the default value (DefaultValueAttribute) for the field
virtual SetDefaultValues() Sets the default values for all fields (DefaultValueAttribute)
virtual SetInternalFields() Sets values for internal fields
virtual SetTrimToEmptyFields() Sets values for TrimToEmpty fields.
virtual ValidateAndClearIdField() Validates and clears the ID field
virtual ValidateEditable() Validates editable fields
virtual ValidateEditableFields(…) Validates editable fields, e.g. checks if the assigned fields are all in the editable set. Calls HandleNonEditable if not.
virtual ValidateFieldValues() Validates field values via ICustomValidator interface.
virtual ValidateIsActive() Validates that record is not soft deleted
virtual ValidatePermissions() Validates user permissions by checking InsertPermissionAttribute and UpdatePermissionAttribute, and ModifyPermissionAttribute or ReadPermissionAttribute if others are not found.
virtual ValidateRequest() Validates the request by checking insert / update permissions.
virtual ValidateRequired(…) Validates required fields

See Also