public static void VerifyGenericDataModelKeyType()

in Elastic.SemanticKernel.Connectors.Elasticsearch/Internal/Helpers/VectorStoreRecordPropertyVerification.cs [177:200]


    public static void VerifyGenericDataModelKeyType(Type recordType, bool customMapperSupplied, IEnumerable<Type> allowedKeyTypes)
    {
        // If we are not dealing with a generic data model, no need to check anything else.
        if (!recordType.IsGenericType || recordType.GetGenericTypeDefinition() != typeof(VectorStoreGenericDataModel<>))
        {
            return;
        }

        // If the key type is supported, we are good.
        var keyType = recordType.GetGenericArguments()[0];
        if (allowedKeyTypes.Contains(keyType))
        {
            return;
        }

        // If the key type is not supported out of the box, but a custom mapper was supplied, we are good.
        if (customMapperSupplied)
        {
            return;
        }

        throw new ArgumentException($"The key type '{keyType.FullName}' of data model '{nameof(VectorStoreGenericDataModel<string>)}' is not supported by the default mappers. " +
            $"Only the following key types are supported: {string.Join(", ", allowedKeyTypes)}. Please provide your own mapper to map to your chosen key type.");
    }