Database Reference
In-Depth Information
For developing in C#, mongocsharpdriver will need to be installed in the project
through NuGet using PM> Install-package mongocsharpdriver . For more
information, see https://www.nuget.org/packages/mongocsharpdriver/ .
We will run through a small sample of C# MongoDB to get acclimatized to MongoDB be-
fore diving into it with NServiceBus. In this example, we will place configurations in the
MongoDB local database.
In order to build data, we need to define the object in a form of BsonDocument , to
which we will add the collection of objects in the database table. BSON is Binary JSON.
For more information, see http://en.wikipedia.org/wiki/BSON . The BsonDocument is
the name-value pair of the data field to the data value that is added to the database. An in-
depth discussion can be found at http://docs.mongodb.org/ecosystem/tutorial/use-csharp-
driver/ . We will connect to the database by setting the connection string in the
app.config file to Server=localhost:27017 :
private static void
CreateMessageMaps(MessageEndpointMappingDB mapping)
{
var client = new MongoClient(ConnectionString);
var server = client.GetServer();
MongoDatabase myConfig =
server.GetDatabase("MyConfig");
MongoCollection<BsonDocument> endpoints =
myConfig.GetCollection<BsonDocument>("MessageEndpointMappingDB");
BsonDocument endpoint = new BsonDocument {
{ "AssemblyName",
mapping.AssemblyName },
Search WWH ::




Custom Search