本文整理汇总了C#中MongoServer.Connect方法的典型用法代码示例。如果您正苦于以下问题:C# MongoServer.Connect方法的具体用法?C# MongoServer.Connect怎么用?C# MongoServer.Connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoServer
的用法示例。
在下文中一共展示了MongoServer.Connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Setup
public void Setup()
{
_server = MongoServer.Create("mongodb://localhost/?safe=true");
_server.Connect();
_database = _server["onlinetests"];
_collection = _database["linqtests"];
}
示例2: Setup
public void Setup()
{
server = MongoServer.Create();
server.Connect();
database = server["onlinetests"];
collection = database["testcollection"];
}
示例3: Setup
public void Setup()
{
server = MongoServer.Create("mongodb://localhost/?safe=true");
server.Connect();
database = server["onlinetests"];
collection = database["testcollection"];
}
示例4: Setup
public void Setup()
{
server = MongoServer.Create("mongodb://localhost/?safe=true");
server.Connect();
server.DropDatabase("onlinetests");
database = server["onlinetests"];
}
示例5: ConnectAsyncTask
public async void ConnectAsyncTask()
{
_mongoServer = null;
MongoClient client = new MongoClient(ConnectionString);
_mongoServer = await Task.Run(() => client.GetServer());
await Task.Run(() => _mongoServer.Connect());
}
示例6: Setup
public void Setup()
{
_server = Configuration.TestServer;
_server.Connect();
_database = Configuration.TestDatabase;
_database.Drop();
}
示例7: Connect
/// <summary>
/// Synchronous connection. This method or <see cref="ConnectAsyncDelegate"/> must be called prior to utilizing the ServerConnection.
/// </summary>
public void Connect()
{
_mongoServer = null;
MongoClient client = new MongoClient(ConnectionString);
_mongoServer = client.GetServer();
_mongoServer.Connect();
}
示例8: Setup
public void Setup()
{
server = MongoServer.Create();
server.Connect();
server.DropDatabase("onlinetests");
database = server["onlinetests"];
}
示例9: MongoRepository
public MongoRepository(MongoUrl mongoUrl, string databaseName)
{
_client = new MongoClient(mongoUrl);
_server = _client.GetServer();
_database = databaseName;
_server.Connect();
}
示例10: Setup
public void Setup()
{
_server = Configuration.TestServer;
_server.Connect();
_database = Configuration.TestDatabase;
_collection = Configuration.TestCollection;
}
示例11: btnConnect_Click
private void btnConnect_Click(object sender, EventArgs e)
{
Card.CardUtility.Init();
innerServer = MongoServer.Create(@"mongodb://localhost:28030");
innerServer.Connect();
innerDatabase = innerServer.GetDatabase("HearthStone");
innerCollection = innerDatabase.GetCollection("Card");
}
示例12: MongoRepository
public MongoRepository(
string connectionString,
string database)
{
_Server = MongoServer.Create(connectionString);
_Database = connectionString.ParseDatabaseName() ?? database;
_Server.Connect();
}
示例13: Init
private void Init(string conStr)
{
MongoUrl url = new MongoUrl(conStr);
string dbName = string.IsNullOrEmpty(url.DatabaseName) ? "TEST" : url.DatabaseName;
Server = MongoServer.Create(conStr);
Server.Connect();
Database = Server.GetDatabase(dbName);
}
示例14: btnImport_Click
/// <summary>
/// 导入按钮事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnImport_Click(object sender, EventArgs e)
{
innerServer = MongoServer.Create(@"mongodb://localhost:28030");
innerServer.Connect();
innerDatabase = innerServer.GetDatabase("HearthStone");
innerCollection = innerDatabase.GetCollection("Card");
if (String.IsNullOrEmpty(ExcelPicker.SelectedPathOrFileName)) return;
Import();
GC.Collect();
innerServer.Disconnect();
}
示例15: OnTestFixtureSetUp
protected virtual void OnTestFixtureSetUp() {
if(IoC.IsNotInitialized)
IoC.Initialize();
if(IsDebugEnabled)
log.Debug("MongoDB 서버에 접속합니다. connectionString=[{0}]", DefaultConnectionString);
Server = MongoServer.Create(DefaultConnectionString);
Server.Connect();
Server.DropDatabase(DefaultDatabaseName);
Database = Server[DefaultDatabaseName];
}