本文整理汇总了C#中MongoDatabase类的典型用法代码示例。如果您正苦于以下问题:C# MongoDatabase类的具体用法?C# MongoDatabase怎么用?C# MongoDatabase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MongoDatabase类属于命名空间,在下文中一共展示了MongoDatabase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IndexModule
public IndexModule(MongoDatabase db)
{
var collection = db.GetCollection<Person>(typeof(Person).Name.ToLower() + "s");
Get["/"] = parameters =>
{
var value = new Random().Next(0, 999);
//SqlConnection connection = new SqlConnection("Data Source=10.0.122.14;Initial Catalog=srm4000;User ID=developers;Password=chicago");
//connection.Open();
//SqlCommand command = new SqlCommand("SELECT * FROM [TABLE] WHERE BATCHNO = " + value, connection);
//SqlDataReader reader = command.ExecuteReader();
//List<Person> people = new List<Person>();
//while (reader.Read())
//{
// var person = new Person { BatchNo = (int)reader["BATCHNO"], Name = (string)reader["NAME"] };
// people.Add(person);
//}
//reader.Close();
//connection.Close();
var foundit = collection.AsQueryable<Person>().Where(x => x.BatchNo == value).ToList();
return 200;
};
}
示例2: GridFsBlobStore
public GridFsBlobStore(MongoDatabase database, ICounterService counterService)
{
_database = database;
_counterService = counterService;
LoadFormatsFromDatabase();
}
示例3: ConnectLocal
private void ConnectLocal(string dbName)
{
var client = new MongoClient(ConnStringLocal);
var server = client.GetServer();
this.Database = server.GetDatabase(dbName);
}
示例4: HugRepository
public HugRepository(string connectionString, string databaseName, IUserProfileRepository userProfileRepository)
{
_userProfileRepository = userProfileRepository;
_server = MongoServer.Create(connectionString);
_database = _server.GetDatabase(databaseName);
_mongoCollection = _database.GetCollection<PenedatingMongoUser>("users");
}
示例5: Setup
public void Setup()
{
_server = Configuration.TestServer;
_primary = Configuration.TestServer.Primary;
_database = Configuration.TestDatabase;
_database.Drop();
}
示例6: Setup
public void Setup()
{
_server = Configuration.TestServer;
_primary = Configuration.TestServer.Primary;
_database = Configuration.TestDatabase;
_collection = Configuration.TestCollection;
}
示例7: Connect
public void Connect(string name = DefaultDbName)
{
var client = new MongoClient(DefaultConnectionString);
var server = client.GetServer();
this.Database = server.GetDatabase(name);
}
示例8: TestFixtureSetUp
public void TestFixtureSetUp()
{
_server = MongoServer.Create(ConnStr);
if (_server.DatabaseExists(PropSetCollectionsDb))
_server.DropDatabase(PropSetCollectionsDb);
_testDb = _server.GetDatabase(PropSetCollectionsDb);
}
示例9: Setup
public void Setup()
{
_server = Configuration.TestServer;
_server.Connect();
_database = Configuration.TestDatabase;
_database.Drop();
}
示例10: Setup
public void Setup()
{
_server = Configuration.TestServer;
_primary = _server.Instances.First(x => ReadPreference.Primary.MatchesInstance(x));
_database = Configuration.TestDatabase;
_collection = Configuration.TestCollection;
}
示例11: EstablishConnection
public static void EstablishConnection()
{
client = new MongoClient(connectionString);
server = client.GetServer();
database = server.GetDatabase(DbName);
entries = database.GetCollection<JSonReport>(collectionName);
}
示例12: Setup
public void Setup()
{
_server = LegacyTestConfiguration.Server;
_primary = _server.Instances.First(x => x.IsPrimary);
_database = LegacyTestConfiguration.Database;
_collection = LegacyTestConfiguration.Collection;
}
示例13: UseCaseUpdateTask
public UseCaseUpdateTask(IAppConfig appConfig, IDataList<UseCase> useCases)
{
var url = new MongoUrl(appConfig.ProxyDbConnectionString);
_db = new MongoClient(url).GetServer().GetDatabase(url.DatabaseName);
_useCases = useCases;
}
示例14: MdbAccount
public MdbAccount()
{
m_Client = new MongoClient(Configuration.Database.Url);
m_Server = m_Client.GetServer();
m_Database = m_Server.GetDatabase(Configuration.Database.Name);
m_Collection = m_Database.GetCollection<Account>(MDBAccountTable);
}
示例15: TestFixtureSetup
public void TestFixtureSetup()
{
server = MongoServer.Create("mongodb://localhost/?safe=true");
database = server["onlinetests"];
collection = database["testcollection"];
collection.Drop();
}