Language

CollectionModelBuilder Class

Definition

Represents a builder for a CollectionModel. This is an internal support type meant for use by providers only and not by applications.

public ref class CollectionModelBuilder abstract
[System.Diagnostics.CodeAnalysis.Experimental("MEVD9001", UrlFormat="https://aka.ms/dotnet-extensions-warnings/{0}")]
public abstract class CollectionModelBuilder
public abstract class CollectionModelBuilder
[<System.Diagnostics.CodeAnalysis.Experimental("MEVD9001", UrlFormat="https://aka.ms/dotnet-extensions-warnings/{0}")>]
type CollectionModelBuilder = class
type CollectionModelBuilder = class
Public MustInherit Class CollectionModelBuilder
Inheritance
CollectionModelBuilder
Derived
Attributes

Remarks

This class is single-use only, and not thread-safe.

Constructors

Name Description
CollectionModelBuilder(CollectionModelBuildingOptions)

Initializes a new instance of the CollectionModelBuilder class.

Properties

Name Description
DataProperties

Gets the data properties of the record.

DefaultEmbeddingGenerator

Gets the default embedding generator to use for vector properties, when none is specified at the property or collection level.

EmbeddingGenerationDispatchers

Gets the embedding types supported by this provider, in priority order. The first type whose embedding generator is compatible with the input type will be used.

KeyProperties

Gets the key properties of the record.

KeyType

Gets the collection's generic key type parameter (TKey), if provided. Used by ValidateKeyProperty(KeyPropertyModel) to validate that TKey corresponds to the key property type on the model.

Options

Gets the options for building the model.

Properties

Gets all properties of the record, of all types.

PropertyMap

Gets all properties of the record, of all types, indexed by their model name.

VectorProperties

Gets the vector properties of the record.

Methods

Name Description
Build(Type, Type, VectorStoreCollectionDefinition, IEmbeddingGenerator)

Builds and returns an CollectionModel from the given recordType and definition.

BuildDynamic(VectorStoreCollectionDefinition, IEmbeddingGenerator)

Builds and returns an CollectionModel for dynamic mapping scenarios from the given definition.

Customize()

Extension hook for providers to be able to customize the model.

IsDataPropertyTypeValid(Type, String)

Validates that the .NET type for a data property is supported by the provider.

IsVectorPropertyTypeValid(Type, String)

Validates that the .NET type for a vector property is supported by the provider.

ProcessProperty(PropertyInfo, VectorStoreProperty)

As part of building the model, this method processes a single property, accepting both a CLR PropertyInfo (from which attributes are read) and a VectorStoreProperty from the user-provided record definition. Either may be null, but not both. When both are provided, the record definition values override attribute-configured values.

SupportsKeyAutoGeneration(Type)

Configures auto-generation for the given key property. Defaults to configuring Guid key properties as auto-generated, and throwing if auto-generation is requested for any other type.

Validate(Type, VectorStoreCollectionDefinition)

Validates the model after all properties have been processed.

ValidateKeyProperty(KeyPropertyModel)

Validates the key property. The default implementation validates that the collection's generic key type (KeyType) corresponds to the key property type on the model, if KeyType was provided. Provider overrides should call the base implementation.

ValidateProperty(PropertyModel, VectorStoreCollectionDefinition)

Validates a single property, performing validation on it.

Applies to