当前位置: 首页>>代码示例>>C#>>正文


C# MongoDatabase类代码示例

本文整理汇总了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;
                };
        }
开发者ID:jchannon,项目名称:MongoTest,代码行数:25,代码来源:IndexModule.cs

示例2: GridFsBlobStore

        public GridFsBlobStore(MongoDatabase database, ICounterService counterService)
        {
            _database = database;
            _counterService = counterService;

            LoadFormatsFromDatabase();
        }
开发者ID:ProximoSrl,项目名称:Jarvis.DocumentStore,代码行数:7,代码来源:GridFsBlobStore.cs

示例3: ConnectLocal

        private void ConnectLocal(string dbName)
        {
            var client = new MongoClient(ConnStringLocal);
            var server = client.GetServer();

            this.Database = server.GetDatabase(dbName);
        }
开发者ID:Team-Neptunium,项目名称:Databases-Team-Neptunium,代码行数:7,代码来源:MongoConnection.cs

示例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");
 }
开发者ID:stawiu,项目名称:penedating,代码行数:7,代码来源:HugRepository.cs

示例5: Setup

 public void Setup()
 {
     _server = Configuration.TestServer;
     _primary = Configuration.TestServer.Primary;
     _database = Configuration.TestDatabase;
     _database.Drop();
 }
开发者ID:KeithLee208,项目名称:mongo-csharp-driver,代码行数:7,代码来源:MongoDatabaseTests.cs

示例6: Setup

 public void Setup()
 {
     _server = Configuration.TestServer;
     _primary = Configuration.TestServer.Primary;
     _database = Configuration.TestDatabase;
     _collection = Configuration.TestCollection;
 }
开发者ID:rjvranjan80,项目名称:mongo-csharp-driver,代码行数:7,代码来源:MongoCollectionTests.cs

示例7: Connect

        public void Connect(string name = DefaultDbName)
        {
            var client = new MongoClient(DefaultConnectionString);
            var server = client.GetServer();

            this.Database = server.GetDatabase(name);
        }
开发者ID:Astatine-Haphazard,项目名称:AstatineTeamwork,代码行数:7,代码来源:MongoContext.cs

示例8: TestFixtureSetUp

 public void TestFixtureSetUp()
 {
     _server = MongoServer.Create(ConnStr);
     if (_server.DatabaseExists(PropSetCollectionsDb))
         _server.DropDatabase(PropSetCollectionsDb);
     _testDb = _server.GetDatabase(PropSetCollectionsDb);
 }
开发者ID:KlaudWerk,项目名称:WSHumanTask,代码行数:7,代码来源:MongoPropertySchemaSetTest.cs

示例9: Setup

 public void Setup()
 {
     _server = Configuration.TestServer;
     _server.Connect();
     _database = Configuration.TestDatabase;
     _database.Drop();
 }
开发者ID:robinNode,项目名称:mongo-csharp-driver,代码行数:7,代码来源:MongoDatabaseTests.cs

示例10: Setup

 public void Setup()
 {
     _server = Configuration.TestServer;
     _primary = _server.Instances.First(x => ReadPreference.Primary.MatchesInstance(x));
     _database = Configuration.TestDatabase;
     _collection = Configuration.TestCollection;
 }
开发者ID:RepoCorp,项目名称:mongo-csharp-driver,代码行数:7,代码来源:MongoCollectionTests.cs

示例11: EstablishConnection

 public static void EstablishConnection()
 {
     client = new MongoClient(connectionString);
     server = client.GetServer();
     database = server.GetDatabase(DbName);
     entries = database.GetCollection<JSonReport>(collectionName);
 }
开发者ID:VyaraGGeorgieva,项目名称:TelerikAcademy,代码行数:7,代码来源:MongoDbReportReader.cs

示例12: Setup

 public void Setup()
 {
     _server = LegacyTestConfiguration.Server;
     _primary = _server.Instances.First(x => x.IsPrimary);
     _database = LegacyTestConfiguration.Database;
     _collection = LegacyTestConfiguration.Collection;
 }
开发者ID:p3p3pp3,项目名称:mongo-csharp-driver-for-tokumx,代码行数:7,代码来源:MongoCollectionTests.cs

示例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;
        }
开发者ID:ryanande,项目名称:ApiProxy,代码行数:7,代码来源:UseCaseUpdateTask.cs

示例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);
 }
开发者ID:rickisme,项目名称:server,代码行数:7,代码来源:MdbAccount.cs

示例15: TestFixtureSetup

 public void TestFixtureSetup()
 {
     server = MongoServer.Create("mongodb://localhost/?safe=true");
     database = server["onlinetests"];
     collection = database["testcollection"];
     collection.Drop();
 }
开发者ID:kamaradclimber,项目名称:mongo-csharp-driver,代码行数:7,代码来源:CSharp282Tests.cs


注:本文中的MongoDatabase类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。