@@ -250,6 +250,7 @@ public static VectorStoreCollection<TKey, TRecord> GetVectorCollection<TKey, TRe
250250 where TRecord : class
251251 {
252252 IDatabase database ;
253+ VectorStore vectorStore ;
253254 VectorStoreCollection < TKey , TRecord > collection = null ;
254255
255256 //TODO: If the logic becomes overly complex in the future, different combinations can be considered to be separated into different libraries
@@ -258,10 +259,8 @@ public static VectorStoreCollection<TKey, TRecord> GetVectorCollection<TKey, TRe
258259 {
259260 case VectorDBType . Memory :
260261 {
261- using ( var inMemoryVectorStore = new InMemoryVectorStore ( ) )
262- {
263- collection = inMemoryVectorStore . GetCollection < TKey , TRecord > ( name , vectorStoreRecordDefinition ) ;
264- }
262+ vectorStore = new InMemoryVectorStore ( ) ;
263+ collection = vectorStore . GetCollection < TKey , TRecord > ( name , vectorStoreRecordDefinition ) ;
265264 break ;
266265 }
267266 case VectorDBType . HardDisk :
@@ -298,17 +297,13 @@ public static VectorStoreCollection<TKey, TRecord> GetVectorCollection<TKey, TRe
298297 }
299298 case VectorDBType . Qdrant :
300299 {
301- using ( var qdrantVectorStore = new QdrantVectorStore ( new QdrantClient ( vectorDb . ConnectionString ) , ownsClient : true ) )
302- {
303- collection = qdrantVectorStore . GetCollection < TKey , TRecord > ( name , vectorStoreRecordDefinition ) ;
304- }
300+ vectorStore = new QdrantVectorStore ( new QdrantClient ( vectorDb . ConnectionString ) , ownsClient : true ) ;
301+ collection = vectorStore . GetCollection < TKey , TRecord > ( name , vectorStoreRecordDefinition ) ;
305302 break ;
306303 }
307304 default :
308- using ( var inMemoryVectorStore = new InMemoryVectorStore ( ) )
309- {
310- collection = inMemoryVectorStore . GetCollection < TKey , TRecord > ( name , vectorStoreRecordDefinition ) ;
311- }
305+ vectorStore = new InMemoryVectorStore ( ) ;
306+ collection = vectorStore . GetCollection < TKey , TRecord > ( name , vectorStoreRecordDefinition ) ;
312307 break ;
313308 }
314309
0 commit comments