| File: RecordAttributes\VectorStoreKeyAttribute.cs | |
| Project: ..\..\..\src\Libraries\Microsoft.Extensions.VectorData.Abstractions\Microsoft.Extensions.VectorData.Abstractions.csproj (Microsoft.Extensions.VectorData.Abstractions) |
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; namespace Microsoft.Extensions.VectorData; /// <summary> /// Defines an attribute to mark a property on a record class as the key under which the record is stored in a vector store. /// </summary> /// <remarks> /// The characteristics defined here influence how the property is treated by the vector store. /// </remarks> [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)] public sealed class VectorStoreKeyAttribute : Attribute { /// <summary> /// Gets an optional name to use for the property in storage, if different from the property name. /// </summary> /// <remarks> /// For example, the property name might be "MyProperty" and the storage name might be "my_property". /// </remarks> public string? StorageName { get; init; } /// <summary> /// Gets or sets a value indicating whether this key property's value is auto-generated or not. /// </summary> /// <remarks> /// The availability of auto-generated properties - as well as the .NET types supported for them - varies across provider implementations. /// </remarks> public bool IsAutoGenerated { // The getter returns GetValueOrDefault() rather than throwing, as a workaround for a C# compiler limitation: // Nullable<bool> cannot be used as a compile-time attribute argument, so the public property must be bool. get => IsAutoGeneratedNullable.GetValueOrDefault(); set => IsAutoGeneratedNullable = value; } /// <summary> /// Gets whether this key property's value is auto-generated or not, or <see langword="null" /> if not set. /// </summary> internal bool? IsAutoGeneratedNullable { get; private set; } }