Link Search Menu Expand Document

IClassHandler


This interface is used to mark a class to be a class handler object. This interface has TEntity generic types in which being used at both the Get() and Set() methods.

Generic Types

Below is the list of generic types.

NameDescription
TEntityRefers to the type of the entity type. This type is used as the input to and result type of the Get() and Set() methods.

Methods

Below is the list of methods.

NameDescription
GetThe method that is being invoked when the outbound execution is triggered (i.e.: Query, QueryAll and BatchQuery).
SetThe method that is being invoked when the inbound execution is triggered (i.e.: Insert, Update, Merge and etc).

How to Implement?

You have to manually create a class that implements this interface.

public class PersonClassHandler : IClassHandler<Person>
{
    public Person Get(Person input, ClassHandlerGetOptions options)
    {
        // Handle the Class before sending back to the caller
    }

    public string Set(Person input, ClassHandlerSetOptions options)
    {
        // Handle the Class before sending to DB
    }
}

How to Map?

There are various ways of mapping a class handler into an entity model. You can use either do the following approach.

Via the ClassHandlerMapper class.

PropertyHandlerMapper
    .Add(typeof(Person), new PersonClassHandler(), true);

Or, via the FluentMapper class.

FluentMapper
    .Entity<Person>()
    .ClassHandler<PersonClassHandler>();

Or, via an explicit ClassHandler attribute.

[ClassHandler(typeof(PersonClassHandler))]
publi class Person
{
    ...
}