Skip to content

Latest commit

 

History

History
81 lines (58 loc) · 2.05 KB

File metadata and controls

81 lines (58 loc) · 2.05 KB
layout default
sidebar interfaces
title IClassHandler
permalink /interface/iclasshandler
tags
repodb
iclasshandler
parent INTERFACES

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.

Name Description
TEntity Refers 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.

Name Description
Get The method that is being invoked when the outbound execution is triggered (i.e.: Query, QueryAll and BatchQuery).
Set The 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
{
    ...
}