Partager via


IVectorStoreRecordCollection<TKey,TRecord>.GetAsync Method

Definition

Gets a record from the vector store. Does not guarantee that the collection exists. Returns null if the record is not found.

public System.Threading.Tasks.Task<TRecord?> GetAsync (TKey key, Microsoft.SemanticKernel.Data.GetRecordOptions? options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member GetAsync : 'Key * Microsoft.SemanticKernel.Data.GetRecordOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Record (requires 'Record : null)>
Public Function GetAsync (key As TKey, Optional options As GetRecordOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of TRecord)

Parameters

key
TKey

The unique id associated with the record to get.

options
GetRecordOptions

Optional options for retrieving the record.

cancellationToken
CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

Task<TRecord>

The record if found, otherwise null.

Exceptions

Throw when the command fails to execute for any reason.

Throw when mapping between the storage model and record data model fails.

Applies to