ListRequestHandler<TRow,TListRequest,TListResponse> class

namespace: Serenity.Services   assemblySerenity.Net.Services

Generic base class for list request handlers

public class ListRequestHandler<TRow, TListRequest, TListResponse> : 
    IListHandler<TRow, TListRequest, TListResponse>, IListRequestProcessor
    where TRow : class, IRow, new()
    where TListRequest : ListRequest
    where TListResponse : ListResponse<TRow>, new()
parameter description
TRow Entity type
TListRequest List request type
TListResponse List response type

Public Members

name description
ListRequestHandler(…) Creates an instance of the class
Cache { get; } Gets the two level cache from the request context
Connection { get; } Gets current connection
Context { get; } Gets the request context
DistinctFields { get; } Gets list of distinct fields
Localizer { get; } Gets localizer from the request context
Permissions { get; } Gets permission service from the request context
Query { get; } Gets the select query
Request { get; protected set; } Response object
Response { get; protected set; } Response object
Row { get; protected set; } The entity used for querying / metadata lookup
StateBag { get; } A state bag for behaviors to preserve state among their methods. It will be cleared before each request, e.g. Process call.
User { get; } Gets current user from the request context
GetDistinctFields() Gets an array of distinct fields by checking Request.DistinctFields. It might be different than the passed list, if the list contains an invalid field or a field that is not allowed to be selected, like NotMapped and Never etc.
IgnoreEqualityFilter(…) Adds the field to the list of ignored equality filters, so that having this field in the Request.EqualityFilter won't raise an exception
Process(…) Processes the list request. This is the entry point for the handler.

Protected Members

name description
behaviors- Lazy list of behaviors that is activated for this request
ignoredEqualityFilters- Set of ignored equality filter entries
lookupAccessMode- True if the list handler is in lookup access mode, e.g. it only allows access to lookup fields
virtual AddFieldContainsCriteria(…) Applies a contains criteria based on containsText, id (if the contains text can be parsed to an integer ID), searchType and numericOnly parameters.
virtual AllowSelectField(…) Returns true if the field should be allowed to be selected, based on is read permission, selectlevel.never flag, and lookup access mode
virtual ApplyContainsText(…) Applies contains text filter to the query
virtual ApplyCriteria(…) Applies the Request.Criteria to the query if it is not null or empty, and replaced field references with their corresponding expressions by calling ReplaceFieldExpressions
virtual ApplyEqualityFilter(…) Applies the Request.Equality filter to the query
virtual ApplyFieldContainsText(…) Applies a field contains criteria to the query by calling AddFieldContainsCriteria
virtual ApplyFieldEqualityFilter(…) Applies a field equality filter, e.g. one that is passed via Request.EqualityFilter to the query. It validates field flags like DenyFiltering and NotMapped and Never to check if the field is allowed to be filtered.
virtual ApplyFilters(…) Applies all the filters including Request.EqualityFilter, Request.Criteria and Request.IncludeDeleted to the query.
virtual ApplyIncludeDeletedFilter(…) Applies include deleted filter to the query if Request.IncludeDeleted is true
virtual ApplyKeyOrder(…) Applies the key order which is ID field (IIdRow)
virtual ApplySort(…) Applies the Request.Sort order to the query. Sorts by GetNativeSort if no sort columns are passed, or the list is empty.
virtual ApplySortBy(…) Applies a sort order to the query
virtual CreateQuery() Creates a query instance with the dialect for current connection.
virtual GetBehaviors() Gets the list of list behaviors
virtual GetNativeSort() Gets the native sort order, which includes name field by default, unless the row has [SortOrder] attributes.
virtual GetQuickSearchFields(…) Gets the list of quick search fields (QuickSearchAttribute) based on the containsField argument.
IsEmptyEqualityFilterValue(…) Checks if the equality filter value is empty. It returns true for null, empty string, or empty IEnumerable.
IsIncluded(…) Returns true if field is included in IncludeColumns (2 methods)
virtual OnAfterExecuteQuery() Called after executing the list query
virtual OnBeforeExecuteQuery() Called before executing the list query
virtual OnReturn() Called just before returning the response
virtual PrepareQuery(…) Prepares query by calling SelectFields.
virtual ProcessEntity(…) Can be overridden in a derived class to make some changes in a returned entity just before it gets added to the Response.Entities list
virtual ReplaceFieldExpressions(…) Replaces field references, e.g. property names and field name with their corresponding expression by using the CriteriaFieldExpressionReplacer
virtual SelectField(…) Calls query.Select(field)
virtual SelectFields(…) Calls query.Select(field) for all the fields without NotMapped, and if AllowSelectField and ShouldSelectField returns true.
virtual ShouldSelectField(…) Returns true if the field should be selected, based on current ColumnSelection, field MinSelectLevelAttribute, the field being a not mapped (NotMappedAttribute) field, table field, or a view / expression field.
virtual ValidatePermissions() Validates if the user is allowed to query this entity type by checking ReadPermissionAttribute and ServiceLookupPermissionAttribute if the request is in lookup access mode.
virtual ValidateRequest() Validates the request by calling ValidatePermissions

See Also