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.

Working with MongoDB documents in C#

Working with MongoDB documents in C# - MongoDB Tutorial

From the course: MongoDB C# Developer Associate Cert Prep

Working with MongoDB documents in C#

- Welcome. In this video we'll define BSON and explain how BSON documents are expressed in C# by using the BSON document class. Then we'll structure a BSON document by using the MongoDB.Bson package. Binary JSON or BSON is the data format that MongoDB uses to organize and store data. BSON is optimized for storage, retrieval and transmission across the wire. BSON is more secure than plain text JSON which is vulnerable to JSON injection attacks. BSON also supports more data types than JSON. MongoDB objects are represented in C# in two main ways, as a BSON document and as a C# class. The first approach to working with BSON documents is to use the BSON document class provided by the MongoDB.Bson package. If you know the names and types of the fields in the MongoDB document, you can recreate the document. This approach is useful if you have a schemaless design where the fields are unknown. In this example, we import the…

Contents