From the course: MongoDB C# Developer Associate Cert Prep
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
Inserting a document in C# applications - MongoDB Tutorial
From the course: MongoDB C# Developer Associate Cert Prep
Inserting a document in C# applications
- Welcome. In this video, you'll learn how to insert new MongoDB documents in C#. There are two methods that you can use to insert a new document into MongoDB, InsertOne and InsertMany. Both of these methods also have an async version, InsertOneAsync and InsertManyAsync, which allow you to insert documents asynchronously. Let's explore how these methods work. To insert a single document into a MongoDB collection, we use the InsertOne method. In this example, we're going to insert a new checking account owned by Linus Torvalds into the Account collection. First thing we want to do is call GetCollection on the database, specifying the type of collection and the name account in this case. We'll save it as the Accounts collection. The next thing we do is create a new account object where we pass in the properties, the account ID, holder, type, and balance. And then, finally, on the Accounts collection, we call…
Contents
-
-
-
-
-
-
-
-
-
(Locked)
Working with MongoDB documents in C#3m 11s
-
(Locked)
Inserting a document in C# applications3m 41s
-
(Locked)
Querying a MongoDB collection in C# applications4m 12s
-
(Locked)
Updating documents in C# applications4m 35s
-
(Locked)
Deleting documents in C# applications4m 25s
-
(Locked)
Creating MongoDB transactions in C# applications3m 11s
-
(Locked)
MongoDB CRUD operations in C# review1m 3s
-
(Locked)
-
-
-
-
-
-
-