本文整理汇总了C#中MongoServer.GetDatabase方法的典型用法代码示例。如果您正苦于以下问题:C# MongoServer.GetDatabase方法的具体用法?C# MongoServer.GetDatabase怎么用?C# MongoServer.GetDatabase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoServer
的用法示例。
在下文中一共展示了MongoServer.GetDatabase方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PatientRepository
public PatientRepository()
{
_server = new MongoServer(new MongoServerSettings { Server = new MongoServerAddress(_DBHOST), SafeMode = SafeMode.True });
//patients
_patients = _server.GetDatabase(_DBNAME).GetCollection<PatientModel>("patients");
_patients.EnsureIndex(IndexKeys.Ascending("_id"), IndexOptions.SetUnique(true));
_gridFS = _server.GetDatabase(_DBNAME).GridFS;
new MongoDB.Web.Providers.MongoDBMembershipProvider();
}
示例2: Impl
public Impl(MongoServer connection, WriteConcern writeConcern)
{
_writeConcern = writeConcern;
new Random(BitConverter.ToInt32(Guid.NewGuid().ToByteArray().Take(4).ToArray(), 0)).NextBytes(_initialValue);
_collection =
connection.GetDatabase(typeof (SomeDocument).Name).GetCollection<SomeDocument>(typeof (SomeDocument).Name);
}
示例3: PersistToMongo
public PersistToMongo(string connectionString)
{
_mongoServer = new MongoClient(connectionString).GetServer();
string databaseName = MongoUrl.Create(connectionString).DatabaseName;
_mongoDatabase = _mongoServer.GetDatabase(databaseName);
_mongoCollection = _mongoDatabase.GetCollection(COLLECTION_NAME);
}
示例4: MOngoTests
public MOngoTests()
{
server = MongoServer.Create();
database = server.GetDatabase("Diplome");
collection = database.GetCollection<Test>("companies");
collection.RemoveAll();
}
示例5: PersonRepository
public PersonRepository()
{
string connectionString = "mongodb://localhost";
_server = MongoServer.Create(connectionString);
_peopleDb = _server.GetDatabase("Mono");
_people = _peopleDb.GetCollection<Person>("Person");
}
示例6: MongoRepositoryContext
static MongoRepositoryContext() {
settings = new MongoRepositorySettings();
var url = new MongoUrl(ConfigurationManager.ConnectionStrings["SysDB"].ConnectionString);
client = new MongoClient(url);
server = client.GetServer();
database = server.GetDatabase(url.DatabaseName);
}
示例7: MongoImpl
public MongoImpl(MongoServer connection, WriteConcern writeConcern)
{
this.writeConcern = writeConcern;
Helpers.Random.Value.NextBytes(initialValue);
collection =
connection.GetDatabase(typeof (SomeDocument).Name).GetCollection<SomeDocument>(typeof (SomeDocument).Name);
}
示例8: MongoEventStore
public MongoEventStore(IMongoConfiguration mongoConfiguration, IEventBus eventBus)
: base(eventBus)
{
_server = MongoServer.Create(mongoConfiguration.Url);
var mongoDatabaseSettings = _server.CreateDatabaseSettings(mongoConfiguration.DatabaseName);
_database = _server.GetDatabase(mongoDatabaseSettings);
}
示例9: ConnectDB
public void ConnectDB()
{
string connectionString = "mongodb://appharbor:[email protected]:10061/238c698d_a07f_425c_a07d_155064079ba8";
client = new MongoClient(connectionString);
server = client.GetServer();
db = server.GetDatabase("238c698d_a07f_425c_a07d_155064079ba8");
}
示例10: ContactRepository
public ContactRepository(string connection)
{
if (string.IsNullOrWhiteSpace(connection))
{
connection = "mongodb://localhost:27017";
}
_client = new MongoClient(connection);
_server = _client.GetServer();
_database = _server.GetDatabase("Contacts", WriteConcern.Unacknowledged);
_contacts = _database.GetCollection<Contact>("contacts");
// Reset database and add some default entries
_contacts.RemoveAll();
for (int index = 1; index < 5; index++)
{
Contact contact1 = new Contact
{
Email = string.Format("test{0}@example.com", index),
Name = string.Format("test{0}", index),
Phone = string.Format("{0}{0}{0} {0}{0}{0} {0}{0}{0}{0}", index)
};
AddContact(contact1);
}
}
示例11: TestFixture_Setup
public void TestFixture_Setup()
{
_server = new MongoServer();
_db = _server.GetDatabase("TestSuiteDatabase");
DroppedCollectionResponse collResponse = _db.DropCollection("TestClasses");
_coll = _db.GetCollection<TestClass>("TestClasses");
}
示例12: InitializeConnection
public static void InitializeConnection()
{
client =
new MongoClient("mongodb://chatuser:[email protected]:63779/mongochat");
server = client.GetServer();
db = server.GetDatabase("mongochat");
}
示例13: TestFixtureSetup
public void TestFixtureSetup()
{
_server = Configuration.TestServer;
_adminDatabase = _server.GetDatabase("admin");
_database = Configuration.TestDatabase;
_primary = _server.Primary;
}
示例14: TodoRepository
public TodoRepository(string connection)
{
if (string.IsNullOrWhiteSpace(connection))
{
connection = ConfigurationManager.AppSettings["TodoConnectionString"];
}
_server = MongoServer.Create(connection);
_database = _server.GetDatabase(ConfigurationManager.AppSettings["TodoDatabaseName"], SafeMode.True);
_todos = _database.GetCollection<Todo>(ConfigurationManager.AppSettings["TodoTableName"]);
bool resetData = true;
bool.TryParse(ConfigurationManager.AppSettings["ResetData"], out resetData);
if (resetData)
{
_todos.RemoveAll();
for (int i = 0; i < 5; i++)
{
Todo todo = new Todo
{
Description = string.Format("Todo {0}", i + 1),
Done = (i % 3 == 0 ? true : false),
CreationDatetime = DateTime.Now,
DoneDatetime = null
};
if (todo.Done)
todo.DoneDatetime = DateTime.Now;
AddTodo(todo);
}
}
}
示例15: MongoContext
public MongoContext(string connectionString)
{
this.connectionString = connectionString;
this.server = MongoServer.Create(this.connectionString);
string databaseName = GetDatabaseName(this.connectionString);
this.database = server.GetDatabase(databaseName);
}