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


C# MongoServer.GetDatabase方法代码示例

本文整理汇总了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();
        }
开发者ID:snasser,项目名称:patient_portal,代码行数:11,代码来源:PatientRepository.cs

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

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

示例4: MOngoTests

 public MOngoTests()
 {
     server = MongoServer.Create();
     database = server.GetDatabase("Diplome");
     collection = database.GetCollection<Test>("companies");
        collection.RemoveAll();
 }
开发者ID:3guboff,项目名称:Diplome,代码行数:7,代码来源:MOngoTests.cs

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

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

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

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

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

示例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);
            }
        }
开发者ID:wk-j,项目名称:asp-samples,代码行数:25,代码来源:ContactRepository.cs

示例11: TestFixture_Setup

 public void TestFixture_Setup()
 {
     _server = new MongoServer();
     _db = _server.GetDatabase("TestSuiteDatabase");
     DroppedCollectionResponse collResponse = _db.DropCollection("TestClasses");
     _coll = _db.GetCollection<TestClass>("TestClasses");
 }
开发者ID:sdether,项目名称:NoRM,代码行数:7,代码来源:WhereQualifierTests.cs

示例12: InitializeConnection

 public static void InitializeConnection()
 {
     client =
         new MongoClient("mongodb://chatuser:[email protected]:63779/mongochat");
     server = client.GetServer();
     db = server.GetDatabase("mongochat");
 }
开发者ID:GenoGenov,项目名称:TelerikAcademyAssignments,代码行数:7,代码来源:ChatSystemData.cs

示例13: TestFixtureSetup

 public void TestFixtureSetup()
 {
     _server = Configuration.TestServer;
     _adminDatabase = _server.GetDatabase("admin");
     _database = Configuration.TestDatabase;
     _primary = _server.Primary;
 }
开发者ID:kobeontheway,项目名称:mongo-csharp-driver,代码行数:7,代码来源:QueryBuilderTests.cs

示例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);
                }
            }
        }
开发者ID:brucculeri-elipse,项目名称:testwebapi,代码行数:34,代码来源:TodoRepository.cs

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


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