Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Upload multiple Document (bulk) in Document DB

I have Documents list(object) that object has multiple documents i.e. Json records are present but while I try to upload that Bunches of Document(Records) it not upload on document DB but while I upload Single Document records it upload succesfully.

  List<MyModelClass> listObj = new List<MyModelClass>();
  Document doc = await DocumentClient.CreateDocumentAsync("dbs/" + DocumentDatabase.Id + "/colls/" + DocumentCollection.Id, listObj);

above code is not working.....

   foreach (var item in listObj )
    {
      Document doc = await Client.CreateDocumentAsync("dbs/" + DocumentDatabase.Id + "/colls/" + DocumentCollection.Id, item);
    }

This code is working for me.....

 Syntax : CreateDocumentAsync(String, Object, RequestOptions, Boolean)
 Object :- Document object // I Know it as per syntax it need to be "Document Type".

I want any Other way to Upload All Document at Once....

like image 892
Pravin Sharma Avatar asked Mar 17 '16 14:03

Pravin Sharma


People also ask

How can you randomly insert a batch of documents into MongoDB at once?

Introduction to insertMany() in PyMongo If you're using MongoDB to store data, there will be times when you want to insert multiple documents into a collection at once. It's easy to accomplish this task with Python when you use the collection. insert_many() method.


1 Answers

It is possible now to insert multiple documents at once by using Microsoft.Azure.CosmosDB.BulkExecutor library

https://docs.microsoft.com/en-us/azure/cosmos-db/bulk-executor-dot-net

like image 112
Dmitry Dzygin Avatar answered Sep 28 '22 04:09

Dmitry Dzygin