OracleVectorToDoubleArrayPropertyHandler

A property handler that maps the Oracle VECTOR type into a double array property.

A property handler that maps the Oracle VECTOR type into a double array property.

Overview

Name Description
Class OracleVectorToDoubleArrayPropertyHandler
Namespace RepoDb.PropertyHandlers.Oracle
Package RepoDb.Oracle
Implements IPropertyHandler<object, double[]>
Column type The Oracle VECTOR type
Property type double[]

Conversions

Method Direction Description
Get Database to property Converts the value returned by the driver (an OracleVector, a float[], a double[], or a JSON array string such as [1.5,2.5]) into a double[]. null, DBNull, a null vector and an empty string are returned as null.
Set Property to database Converts the double[] into an OracleVector (FLOAT64), to be written into the VECTOR column. A null array is written as null.

Exceptions

Exception Thrown When
ArgumentException The type of the value returned by the driver is not supported.

Usability

Bind the handler to the property that maps to a VECTOR column.

Attribute

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

    [Map("vector"), PropertyHandler(typeof(OracleVectorToDoubleArrayPropertyHandler))]
    public double[] Vector { get; set; }
}

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

using (var connection = new OracleConnection(connectionString))
{
    connection.Insert(new Embedding { Id = 1, Vector = new double[] { 1.5, 2.5, 3.5 } });
    var embedding = connection.Query<Embedding>(e => e.Id == 1).First();
}

Fluent Mapping

To configure via FluentMapper:

FluentMapper
    .Entity<Embedding>()
    .PropertyHandler<OracleVectorToDoubleArrayPropertyHandler>(e => e.Vector);

Property Level Mapping

To configure via PropertyHandlerMapper:

PropertyHandlerMapper.Add<Embedding, OracleVectorToDoubleArrayPropertyHandler>(e => e.Vector, new OracleVectorToDoubleArrayPropertyHandler(), true);

Type Level Mapping

To apply the handler to every property of the type double[]:

PropertyHandlerMapper.Add<double[], OracleVectorToDoubleArrayPropertyHandler>(new OracleVectorToDoubleArrayPropertyHandler(), true);

A type level mapping is process-wide: it is applied to every double[] property of every entity and connection, not only to the intended column. Prefer the attribute, fluent or property level mapping unless every double[] property maps to a VECTOR column.

See Also