diff --git a/dotnet/Directory.Packages.props b/dotnet/Directory.Packages.props
index 3c5217f13345..f16128c50b63 100644
--- a/dotnet/Directory.Packages.props
+++ b/dotnet/Directory.Packages.props
@@ -161,7 +161,7 @@
-
+
diff --git a/dotnet/src/IntegrationTests/Connectors/Memory/CosmosMongoDB/CosmosMongoVectorStoreFixture.cs b/dotnet/src/IntegrationTests/Connectors/Memory/CosmosMongoDB/CosmosMongoVectorStoreFixture.cs
index 2aa0511e9289..f4427b6d5bef 100644
--- a/dotnet/src/IntegrationTests/Connectors/Memory/CosmosMongoDB/CosmosMongoVectorStoreFixture.cs
+++ b/dotnet/src/IntegrationTests/Connectors/Memory/CosmosMongoDB/CosmosMongoVectorStoreFixture.cs
@@ -40,7 +40,9 @@ public CosmosMongoVectorStoreFixture()
.Build();
var connectionString = GetConnectionString(configuration);
+#pragma warning disable CA2000 // Dispose objects before losing scope
var client = new MongoClient(connectionString);
+#pragma warning restore CA2000
this.MongoDatabase = client.GetDatabase("test");
diff --git a/dotnet/src/IntegrationTests/Connectors/Memory/MongoDB/MongoDBVectorStoreFixture.cs b/dotnet/src/IntegrationTests/Connectors/Memory/MongoDB/MongoDBVectorStoreFixture.cs
index 51ca1e3565da..5a17920cff6f 100644
--- a/dotnet/src/IntegrationTests/Connectors/Memory/MongoDB/MongoDBVectorStoreFixture.cs
+++ b/dotnet/src/IntegrationTests/Connectors/Memory/MongoDB/MongoDBVectorStoreFixture.cs
@@ -37,11 +37,13 @@ public async Task InitializeAsync()
cts.CancelAfter(TimeSpan.FromSeconds(60));
await this._container.StartAsync(cts.Token);
+#pragma warning disable CA2000 // Dispose objects before losing scope
var mongoClient = new MongoClient(new MongoClientSettings
{
Server = new MongoServerAddress(this._container.Hostname, this._container.GetMappedPublicPort(MongoDbBuilder.MongoDbPort)),
DirectConnection = true,
});
+#pragma warning restore CA2000
this.MongoDatabase = mongoClient.GetDatabase("test");
diff --git a/dotnet/src/InternalUtilities/connectors/Memory/MongoDB/BsonValueFactory.cs b/dotnet/src/InternalUtilities/connectors/Memory/MongoDB/BsonValueFactory.cs
new file mode 100644
index 000000000000..6787d9e07166
--- /dev/null
+++ b/dotnet/src/InternalUtilities/connectors/Memory/MongoDB/BsonValueFactory.cs
@@ -0,0 +1,30 @@
+// Copyright (c) Microsoft. All rights reserved.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using MongoDB.Bson;
+
+namespace Microsoft.SemanticKernel.Connectors.MongoDB;
+
+///
+/// A class that constructs the correct BsonValue for a given CLR type.
+///
+internal static class BsonValueFactory
+{
+ ///
+ /// Create a BsonValue for the given CLR type.
+ ///
+ /// The CLR object to create a BSON value for.
+ /// The appropriate for that CLR type.
+ public static BsonValue Create(object? value)
+ => value switch
+ {
+ null => BsonNull.Value,
+ Guid guid => new BsonBinaryData(guid, GuidRepresentation.Standard),
+ object[] array => new BsonArray(Array.ConvertAll(array, Create)),
+ Array array => new BsonArray(array),
+ IEnumerable