File: ProviderServices\KeyPropertyModel.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;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Shared.DiagnosticIds;
 
namespace Microsoft.Extensions.VectorData.ProviderServices;
 
/// <summary>
/// Represents a key property on a vector store record.
/// This is an internal support type meant for use by providers only and not by applications.
/// </summary>
[Experimental(DiagnosticIds.Experiments.VectorDataProviderServices, UrlFormat = DiagnosticIds.UrlFormat)]
public class KeyPropertyModel(string modelName, Type type) : PropertyModel(modelName, type)
{
    /// <summary>
    /// Gets or sets a value indicating whether this key property's value is auto-generated or not.
    /// </summary>
    public bool IsAutoGenerated { get; set; }
 
    /// <summary>
    /// Gets or sets the name that the JSON serializer will produce for this key property.
    /// </summary>
    /// <remarks>
    /// This is needed for providers that use an external JSON serializer combined with a reserved key storage name
    /// (for example, CosmosDB NoSQL uses <c>"id"</c>): the serializer produces a JSON object with the
    /// policy-transformed name, and the provider needs to find and replace it with the reserved storage name.
    /// </remarks>
    public string? SerializedKeyName { get; set; }
 
    /// <inheritdoc/>
    public override string ToString()
        => $"{ModelName} (Key, {Type.Name}{(IsAutoGenerated ? ", auto-generated" : string.Empty)})";
}