Skip to content

Configuration

MSugiura edited this page Dec 27, 2023 · 1 revision

Before using RedOrb, you need to configure the environment.

Please set the environment only once within the application.

Parameter query placeholder

Set the symbols used in parameter queries (such as "@" for SQLServer and ":" for Postgresql) to ObjectRelationMapper.

//Postgres sample
ObjectRelationMapper.PlaceholderIdentifer = ":";

Mapping definition

You need to define your model class using attributes. Please refer to the Model page for how to define it.

Register the Model class using the ObjectRelationMapper.AddTypeHandler method.

ObjectRelationMapper.AddTypeHandler(DefinitionBuilder.Create<Blog>());

Sample

Example of initial settings when using xUnit.

using RedOrb;

internal static class UnitTestInitializer
{
    [ModuleInitializer]
    public static void Initialize()
    {
        ObjectRelationMapper.PlaceholderIdentifer = ":";
        ObjectRelationMapper.AddTypeHandler(DefinitionBuilder.Create<Blog>());
        ObjectRelationMapper.AddTypeHandler(DefinitionBuilder.Create<Post>());
    }
}
Clone this wiki locally