Skip to content

obligaron/mongo-csharp-driver

This branch is 73 commits behind mongodb/mongo-csharp-driver:main.

Folders and files

NameName
Last commit message
Last commit date
Oct 16, 2024
Oct 11, 2024
Oct 9, 2024
Nov 21, 2024
Nov 19, 2024
Nov 20, 2024
Nov 21, 2024
Dec 13, 2021
Oct 4, 2023
Mar 3, 2011
Oct 4, 2024
Aug 22, 2023
Apr 29, 2022
Oct 8, 2024
Aug 28, 2024
Aug 10, 2023
Jun 5, 2023
Jul 22, 2024
Jan 29, 2021
Dec 10, 2018
Dec 10, 2018
Dec 10, 2018
Jul 15, 2024
Aug 9, 2022
Nov 7, 2024
May 16, 2024
May 27, 2024
May 16, 2024
Jul 15, 2024
Oct 23, 2024
Oct 23, 2024

Repository files navigation

MongoDB C# Driver

You can get the latest stable release from the official Nuget.org feed or from our github releases page.

Getting Started

Untyped Documents

using MongoDB.Bson;
using MongoDB.Driver;
var client = new MongoClient("mongodb://localhost:27017");
var database = client.GetDatabase("foo");
var collection = database.GetCollection<BsonDocument>("bar");

await collection.InsertOneAsync(new BsonDocument("Name", "Jack"));

var list = await collection.Find(new BsonDocument("Name", "Jack"))
    .ToListAsync();

foreach(var document in list)
{
    Console.WriteLine(document["Name"]);
}

Typed Documents

using MongoDB.Bson;
using MongoDB.Driver;
public class Person
{
    public ObjectId Id { get; set; }
    public string Name { get; set; }
}
var client = new MongoClient("mongodb://localhost:27017");
var database = client.GetDatabase("foo");
var collection = database.GetCollection<Person>("bar");

await collection.InsertOneAsync(new Person { Name = "Jack" });

var list = await collection.Find(x => x.Name == "Jack")
    .ToListAsync();

foreach(var person in list)
{
    Console.WriteLine(person.Name);
}

Documentation

Questions/Bug Reports

If you’ve identified a security vulnerability in a driver or any other MongoDB project, please report it according to the instructions here.

Contributing

Please see our guidelines for contributing to the driver.

Thank you to everyone who has contributed to this project.

Releases

No releases published

Packages

No packages published

Languages

  • C# 99.7%
  • Shell 0.2%
  • Python 0.1%
  • Perl 0.0%
  • PowerShell 0.0%
  • CSS 0.0%