BigIntegerToInt128PropertyHandler

A property handler that maps a 128-bit integer column, which drivers expose as a BigInteger, into a Int128 property.

A property handler that maps a 128-bit integer column (for example, the Firebird INT128 type, which drivers expose as a BigInteger) into an Int128 property.

This handler is compiled only for .NET 8 and later. It is not available on the netstandard2.0 target of the RepoDb package.

Overview

Name Description
Class BigIntegerToInt128PropertyHandler
Namespace RepoDb.PropertyHandlers
Package RepoDb
Implements IPropertyHandler<object, Int128>
Column type A 128-bit integer column (for example, the Firebird INT128 type)
Property type Int128
Availability Not available on the netstandard2.0 target of the package; requires .NET 8 or later.

Conversions

Method Direction Description
Get Database to property Converts the value returned by the driver (a BigInteger, an Int128, a long, or an int) into Int128. null and DBNull are returned as Int128.Zero.
Set Property to database Converts the Int128 into a BigInteger, to be written into the column.

Exceptions

Exception Thrown When
OverflowException The value is outside of the range of an Int128.
ArgumentException The type of the value returned by the driver is not supported.

Usability

Bind the handler to the property that maps to the INT128 column.

Attribute

public class Counter
{
    public int Id { get; set; }

    [Map("total"), PropertyHandler(typeof(BigIntegerToInt128PropertyHandler))]
    public Int128 Total { get; set; }
}

Once bound, the library invokes the handler automatically when the property is read or written.

using (var connection = new FbConnection(connectionString))
{
    connection.Insert(new Counter { Id = 1, Total = Int128.MaxValue });
    var counter = connection.Query<Counter>(e => e.Id == 1).First();
}

Fluent Mapping

To configure via FluentMapper:

FluentMapper
    .Entity<Counter>()
    .PropertyHandler<BigIntegerToInt128PropertyHandler>(e => e.Total);

Property Level Mapping

To configure via PropertyHandlerMapper:

PropertyHandlerMapper.Add<Counter, BigIntegerToInt128PropertyHandler>(e => e.Total, new BigIntegerToInt128PropertyHandler(), true);

Type Level Mapping

To apply the handler to every property of the type Int128:

PropertyHandlerMapper.Add<Int128, BigIntegerToInt128PropertyHandler>(new BigIntegerToInt128PropertyHandler(), true);

See Also