BigIntegerToNullableInt128PropertyHandler
A property handler that maps a 128-bit integer column, which drivers expose as a BigInteger, into a nullable 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 a Nullable<Int128> property.
This handler is compiled only for .NET 8 and later. It is not available on the
netstandard2.0target of the RepoDb package.
Overview
| Name | Description |
|---|---|
| Class | BigIntegerToNullableInt128PropertyHandler |
| 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 Nullable<Int128>. null and DBNull are returned as null. |
| Set | Property to database | Converts the Int128 into a BigInteger, to be written into the column. A null value is written as null. |
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(BigIntegerToNullableInt128PropertyHandler))]
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 = null });
var counter = connection.Query<Counter>(e => e.Id == 1).First();
}
Fluent Mapping
To configure via FluentMapper:
FluentMapper
.Entity<Counter>()
.PropertyHandler<BigIntegerToNullableInt128PropertyHandler>(e => e.Total);
Property Level Mapping
To configure via PropertyHandlerMapper:
PropertyHandlerMapper.Add<Counter, BigIntegerToNullableInt128PropertyHandler>(e => e.Total, new BigIntegerToNullableInt128PropertyHandler(), true);
Type Level Mapping
To apply the handler to every property of the type Int128?:
PropertyHandlerMapper.Add<Int128?, BigIntegerToNullableInt128PropertyHandler>(new BigIntegerToNullableInt128PropertyHandler(), true);