Database Reference
In-Depth Information
{ "Endpoint", mapping.Endpoint },
{ "Messages", mapping.Messages },
{ "Namespace", mapping.Namespace },
{ "TypeFullName",
mapping.TypeFullName }
};
endpoints.Insert(endpoint);
}
We create the BsonDocument , which contains the field names of the database, for in-
stance Server AssemblyName , and sets the associated string value in that field, in
this case, mapping.AssemblyName . The BsonDocument is then inserted into the
database, a collection of rows in endpoints.Insert(endpoint) .
To retrieve the collection of objects, we return the MongoCollection of objects and
transform the collection into an object list:
public static List<MessageEndpointMappingDB>
GetMessageMaps()
{
List<MessageEndpointMappingDB> endpointList = new
List<MessageEndpointMappingDB>();
var client = new MongoClient(ConnectionString);
var server = client.GetServer();
MongoDatabase myConfig =
server.GetDatabase("MyConfig");
MongoCollection<MessageEndpointMappingDB>
endpoints =
myConfig.GetCollection<MessageEndpointMappingDB>("MessageEndpointMappingDB");
foreach (var endpoint in endpoints.FindAll())
{
endpointList.Add(endpoint);
}
return endpointList;
}
Search WWH ::




Custom Search