本文整理汇总了C#中MongoDB.Driver.MongoClient.GetServer方法的典型用法代码示例。如果您正苦于以下问题:C# MongoClient.GetServer方法的具体用法?C# MongoClient.GetServer怎么用?C# MongoClient.GetServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoDB.Driver.MongoClient
的用法示例。
在下文中一共展示了MongoClient.GetServer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RetreiveMongohqDb
private MongoDatabase RetreiveMongohqDb()
{
MongoClient mongoClient = new MongoClient(
new MongoUrl(ConfigurationManager.ConnectionStrings["MongoHQ"].ConnectionString));
MongoServer server = mongoClient.GetServer();
return mongoClient.GetServer().GetDatabase("MyFirstDb");
}
示例2: MongoPersistence
public static Configure MongoPersistence(this Configure config)
{
var connectionStringEntry = ConfigurationManager.ConnectionStrings["NServicebus.Persistence"];
//user existing config if we can find one
if (connectionStringEntry != null)
return MongoPersistenceWithConectionString(config, connectionStringEntry.ConnectionString, null);
var client = new MongoClient(MongoPersistenceConstants.DefaultUrl);
var db = client.GetServer().GetDatabase(DatabaseNamingConvention());
return MongoPersistence(config, client.GetServer(), db);
}
示例3: Insert
public static void Insert()
{
MongoClient client = new MongoClient(strconn);
client.GetServer();
//创建数据库链接
MongoServer server = client.GetServer();// MongoDB.Driver.MongoServer.Create(strconn);
//获得数据库
MongoDatabase db = server.GetDatabase(dbName);
Persons person = new Persons();
person.name = "44444";
person.age = 24;
MongoCollection col = db.GetCollection("person");
col.Insert<Persons>(person);
}
示例4: Main
static void Main()
{
var client = new MongoClient("mongodb://localhost/");
var server = client.GetServer();
var dictionaryDb = server.GetDatabase("Dictionary");
var english = dictionaryDb.GetCollection("English");
Console.WriteLine("Enter command - Add, Change, Find or Exit");
string command = Console.ReadLine();
while (command != exit)
{
if (command == add)
{
AddToDictionary(english);
}
else if (command == change)
{
ChangeTranslation(english);
}
else if (command == find)
{
ShowTranslation(english);
}
else if (command != exit)
{
Console.WriteLine("Enter invalid command. Please try again.");
}
Console.WriteLine("Enter command - Add, Change, Find or Exit");
command = Console.ReadLine();
}
}
示例5: GetCollection
public static MongoCollection<BsonDocument> GetCollection(string collectionName)
{
var mongoclient = new MongoClient(ConfigurationManager.ConnectionStrings["MongoDB"].ConnectionString);
var server = mongoclient.GetServer();
var MongoDatabase = server.GetDatabase("CVServicePoc");
return MongoDatabase.GetCollection(collectionName);
}
示例6: GetMongoContext
public MongoDatabase GetMongoContext()
{
MongoClient client = new MongoClient(path);
MongoServer server = client.GetServer();
MongoDatabase dbContext = server.GetDatabase("mongotelerikchat");
return dbContext;
}
示例7: MongoContext
public MongoContext()
{
var client = new MongoClient(ConfigurationManager.ConnectionStrings[DATABASE].ConnectionString);
var server = client.GetServer();
_database = server.GetDatabase(DATABASE);
}
示例8: EstablishConnection
public static void EstablishConnection()
{
client = new MongoClient(connectionString);
server = client.GetServer();
database = server.GetDatabase(DbName);
entries = database.GetCollection<JSonReport>(collectionName);
}
示例9: GetMongoCollection
private MongoCollection<BsonDocument> GetMongoCollection()
{
var client = new MongoClient(_connectionString);
var db = client.GetServer().GetDatabase(new MongoUrl(_connectionString).DatabaseName);
var collection = db.GetCollection(_collectionName);
return collection;
}
示例10: MongoWorkflowDataAccess
/// <summary>
/// Initializes a new instance of the <see cref="MongoWorkflowDataAccess"/> class.
/// </summary>
/// <param name="configuration">The configuration options.</param>
public MongoWorkflowDataAccess(IMongoConfiguration configuration)
{
this.Configuration = configuration;
MongoClient client = new MongoClient(configuration.ToMongoClientSettings());
this.Server = client.GetServer();
this.Database = this.Server.GetDatabase(configuration.Database);
}
示例11: MigrationRunner
public MigrationRunner(string connectionString, string databaseName, string collectionName = DEFAULT_COLLECTION_NAME)
{
var client = new MongoClient(connectionString);
Database = client.GetServer().GetDatabase(databaseName);
DatabaseStatus = new DatabaseMigrationStatus(this);
MigrationLocator = new MigrationLocator();
}
示例12: GetProductReports
public static List<ProductReportEntity> GetProductReports()
{
List<ProductReportEntity> result = new List<ProductReportEntity>();
string mongoConnectionString = @"mongodb://192.168.193.25:27017/productReport";
MongoClient client = new MongoClient(mongoConnectionString);
MongoServer server = client.GetServer();
MongoDatabase productReportsDb = server.GetDatabase("productReport");
MongoCollection<ProductReportEntity> reportsCollection = productReportsDb.GetCollection<ProductReportEntity>("reports");
var reports =
from report in reportsCollection.AsQueryable<ProductReportEntity>()
select report;
foreach (var report in reports)
{
ProductReportEntity newReport = new ProductReportEntity();
newReport.ProductName = report.ProductName;
newReport.VendorName = report.VendorName;
newReport.TotalIncomes = report.TotalIncomes;
newReport.TotalQuantitySold = report.TotalQuantitySold;
result.Add(newReport);
}
return result;
}
示例13: GetDBFromConnection
public static MongoDatabase GetDBFromConnection(String connectionName)
{
var url = GetMongoDBUrl(connectionName);
var client = new MongoClient(url);
var server = client.GetServer();
return server.GetDatabase(url.DatabaseName);
}
示例14: MongoDictionary
public MongoDictionary(string connectionString, string databaseName, string collectionName)
{
var client = new MongoClient(connectionString);
var server = client.GetServer();
var database = server.GetDatabase(databaseName);
entriesCollection = database.GetCollection<Entry>(collectionName);
}
示例15: WellCastServerEngine
public WellCastServerEngine()
{
//Get a Reference to the Client Object
var mongoClient = new MongoClient( "mongodb://pelustondo:[email protected]:41140/wellcast");
var mongoServer = mongoClient.GetServer();
mdb = mongoServer.GetDatabase("wellcast");
}