• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# MongoDatabase类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MongoDatabase的典型用法代码示例。如果您正苦于以下问题:C# MongoDatabase类的具体用法?C# MongoDatabase怎么用?C# MongoDatabase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MongoDatabase类属于命名空间,在下文中一共展示了MongoDatabase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: CoverDB

        public static void CoverDB(MongoDatabase oldDB, MongoDatabase newDB, string collName, params string[] files)
        {
            MongoCollection oldColl = oldDB.GetCollection(collName);
            MongoCollection newColl = newDB.GetCollection(collName);
            int count = 0;

            var players = oldColl.FindAllAs<BsonDocument>();
            foreach (var doc in players)
            {
                foreach (string filed in files)
                {
                    Change(doc, filed);
                }
                //分离Box中的一点券购买
                if (collName == "PlayerEx")
                {
                    BoxToBuy(doc);
                }
                else if (collName == "Pet")
                {
                    RemovePlayerName(doc);
                }

                newColl.Save(doc);
                count++;
            }
            Console.WriteLine(collName + "转换完成" + count);
        }
开发者ID:abel,项目名称:sinan,代码行数:28,代码来源:CoverDBHelper.cs


示例4: Test2

        public static void Test2(MongoDatabase db)
        {
            var d = new Dictionary<string, object>();
            var pp = new PortalPage { Title = "This is my test", Id = "test1" };
            var pc = new PortalPageColumn();
            pp.Columns.Add(pc);
            pc.Config["width"] = 200;
            d["open"] = "open listener";
            d["close"] = "close listener";
            d["interval"] = 500;
            pc.Config["listeners"] = d;

            d = new Dictionary<string, object>();
            d["open"] = "open listener";
            d["close"] = "close listener";
            d["interval"] = 500;
            pc.Config["listeners"] = d;

            var pt = new Portlet { Title = "test portlet 1", PortletClass = "GraphImage" };
            pt.Config["width"] = 200;
            pt.Config["height"] = 300;
            pt.Config["listeners"] = d;
            pc.Portlets.Add(pt);

            db.GetCollection<PortalPage>().Save(pp);

            var pp2 = db.GetCollection<PortalPage>().FindOneById(pp.Id);
            Console.WriteLine("p2: {0}", pp2.Title);
        }
开发者ID:lafar6502,项目名称:cogmon,代码行数:29,代码来源:Program.cs


示例5: AutoIncrementIdImplementation

 public AutoIncrementIdImplementation(long capacity, MongoDatabase mongo)
 {
     _currentHi = 0;
     _capacity = capacity;
     _mongo = mongo;
     _currentLo = capacity + 1;
 }
开发者ID:dangeabunea,项目名称:MongoBasic,代码行数:7,代码来源:AutoIncrementIdImplementation.cs


示例6: 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


示例7: 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


示例8: Setup

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


示例9: 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


示例10: 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


示例11: 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


示例12: Setup

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


示例13: 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


示例14: 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


示例15: 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


示例16: 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


示例17: 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


示例18: 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


示例19: TestFixtureSetup

 public void TestFixtureSetup()
 {
     _database = Configuration.TestDatabase;
     var collectionSettings = new MongoCollectionSettings() { GuidRepresentation = GuidRepresentation.Standard };
     _collection = _database.GetCollection<C>("csharp714", collectionSettings);
     _collection.Drop();
 }
开发者ID:GGsus,项目名称:mongo-csharp-driver,代码行数:7,代码来源:CSharp714Tests.cs


示例20: PersonRepository

 public PersonRepository()
 {
     string connectionString = "mongodb://localhost";
     _server = MongoServer.Create(connectionString);
     _peopleDb = _server.GetDatabase("Mono");
     _people = _peopleDb.GetCollection<Person>("Person");
 }
开发者ID:henryoswald,项目名称:MongoNancyMono,代码行数:7,代码来源:PersonRepository.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MongoRepository类代码示例发布时间:2022-05-24
下一篇:
C# MongoConnection类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap