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


C# MongoClient.GetServer方法代码示例

本文整理汇总了C#中MongoDB.Driver.MongoClient.GetServer方法的典型用法代码示例。如果您正苦于以下问题:C# MongoClient.GetServer方法的具体用法?C# MongoClient.GetServer怎么用?C# MongoClient.GetServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MongoDB.Driver.MongoClient的用法示例。


在下文中一共展示了MongoClient.GetServer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RetreiveMongohqDb

 private MongoDatabase RetreiveMongohqDb()
 {
     MongoClient mongoClient = new MongoClient(
         new MongoUrl(ConfigurationManager.ConnectionStrings["MongoHQ"].ConnectionString));
     MongoServer server = mongoClient.GetServer();
     return mongoClient.GetServer().GetDatabase("MyFirstDb");
 }
开发者ID:harishminchu,项目名称:starting-mongodb-and-web-api,代码行数:7,代码来源:MongoDbController.cs

示例2: MongoPersistence

        public static Configure MongoPersistence(this Configure config)
        {
            var connectionStringEntry = ConfigurationManager.ConnectionStrings["NServicebus.Persistence"];

            //user existing config if we can find one
            if (connectionStringEntry != null)
                return MongoPersistenceWithConectionString(config, connectionStringEntry.ConnectionString, null);

            var client = new MongoClient(MongoPersistenceConstants.DefaultUrl);
            var db = client.GetServer().GetDatabase(DatabaseNamingConvention());

            return MongoPersistence(config, client.GetServer(), db);
        }
开发者ID:justinsaraceno,项目名称:NServicebus-Mongo,代码行数:13,代码来源:ConfigureMongoPersistence.cs

示例3: Insert

        public static void Insert()
        {
            MongoClient client = new MongoClient(strconn);
            client.GetServer();
            //创建数据库链接
            MongoServer server = client.GetServer();// MongoDB.Driver.MongoServer.Create(strconn);
            //获得数据库
            MongoDatabase db = server.GetDatabase(dbName);

            Persons person = new Persons();
            person.name = "44444";
            person.age = 24;
            MongoCollection col = db.GetCollection("person");
            col.Insert<Persons>(person);
        }
开发者ID:crayoncode,项目名称:MongoDBConnection,代码行数:15,代码来源:Program.cs

示例4: Main

    static void Main()
    {
        var client = new MongoClient("mongodb://localhost/");
        var server = client.GetServer();
        var dictionaryDb = server.GetDatabase("Dictionary");
        var english = dictionaryDb.GetCollection("English");

        Console.WriteLine("Enter command - Add, Change, Find or Exit");
        string command = Console.ReadLine();
        while (command != exit)
        {
            if (command == add)
            {
                AddToDictionary(english);
            }
            else if (command == change)
            {
                ChangeTranslation(english);
            }
            else if (command == find)
            {
                ShowTranslation(english);
            }
            else if (command != exit)
            {
                Console.WriteLine("Enter invalid command. Please try again.");
            }

            Console.WriteLine("Enter command - Add, Change, Find or Exit");
            command = Console.ReadLine();
        }
    }
开发者ID:vasilkrvasilev,项目名称:Databases,代码行数:32,代码来源:MongoDbDictionary.cs

示例5: GetCollection

 public static MongoCollection<BsonDocument> GetCollection(string collectionName)
 {
     var mongoclient = new MongoClient(ConfigurationManager.ConnectionStrings["MongoDB"].ConnectionString);
         var server = mongoclient.GetServer();
         var MongoDatabase = server.GetDatabase("CVServicePoc");
         return MongoDatabase.GetCollection(collectionName);
 }
开发者ID:brosen,项目名称:CVServicePoc,代码行数:7,代码来源:MongoHelper.cs

示例6: GetMongoContext

 public MongoDatabase GetMongoContext()
 {
     MongoClient client = new MongoClient(path);
     MongoServer server = client.GetServer();
     MongoDatabase dbContext = server.GetDatabase("mongotelerikchat");
     return dbContext;
 }
开发者ID:Varbanov,项目名称:TelerikAcademy,代码行数:7,代码来源:MongoChat.xaml.cs

示例7: MongoContext

        public MongoContext()
        {
            var client = new MongoClient(ConfigurationManager.ConnectionStrings[DATABASE].ConnectionString);
            var server = client.GetServer();

            _database = server.GetDatabase(DATABASE);
        }
开发者ID:Beren1h,项目名称:Insight,代码行数:7,代码来源:MongoContext.cs

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

示例9: GetMongoCollection

 private MongoCollection<BsonDocument> GetMongoCollection()
 {
     var client = new MongoClient(_connectionString);
     var db = client.GetServer().GetDatabase(new MongoUrl(_connectionString).DatabaseName);
     var collection = db.GetCollection(_collectionName);
     return collection;
 }
开发者ID:hxzqlh,项目名称:enode,代码行数:7,代码来源:MongoEventPublishInfoStore.cs

示例10: MongoWorkflowDataAccess

 /// <summary>
 /// Initializes a new instance of the <see cref="MongoWorkflowDataAccess"/> class.
 /// </summary>
 /// <param name="configuration">The configuration options.</param>
 public MongoWorkflowDataAccess(IMongoConfiguration configuration)
 {
     this.Configuration = configuration;
     MongoClient client = new MongoClient(configuration.ToMongoClientSettings());
     this.Server = client.GetServer();
     this.Database = this.Server.GetDatabase(configuration.Database);
 }
开发者ID:cgavieta,项目名称:WORKPAC2016-poc,代码行数:11,代码来源:MongoWorkflowDataAccess.cs

示例11: MigrationRunner

 public MigrationRunner(string connectionString, string databaseName, string collectionName = DEFAULT_COLLECTION_NAME)
 {
     var client = new MongoClient(connectionString);
     Database = client.GetServer().GetDatabase(databaseName);
     DatabaseStatus = new DatabaseMigrationStatus(this);
     MigrationLocator = new MigrationLocator();
 }
开发者ID:arpitgold,项目名称:Exceptionless,代码行数:7,代码来源:MigrationRunner.cs

示例12: GetProductReports

        public static List<ProductReportEntity> GetProductReports()
        {
            List<ProductReportEntity> result = new List<ProductReportEntity>();

            string mongoConnectionString = @"mongodb://192.168.193.25:27017/productReport";
            MongoClient client = new MongoClient(mongoConnectionString);
            MongoServer server = client.GetServer();
            MongoDatabase productReportsDb = server.GetDatabase("productReport");

            MongoCollection<ProductReportEntity> reportsCollection = productReportsDb.GetCollection<ProductReportEntity>("reports");
            var reports =
                from report in reportsCollection.AsQueryable<ProductReportEntity>()
                select report;

            foreach (var report in reports)
            {
                ProductReportEntity newReport = new ProductReportEntity();
                newReport.ProductName = report.ProductName;
                newReport.VendorName = report.VendorName;
                newReport.TotalIncomes = report.TotalIncomes;
                newReport.TotalQuantitySold = report.TotalQuantitySold;

                result.Add(newReport);
            }

            return result;
        }
开发者ID:vaster,项目名称:Telerik.vasko,代码行数:27,代码来源:MongoReader.cs

示例13: GetDBFromConnection

 public static MongoDatabase GetDBFromConnection(String connectionName)
 {
     var url = GetMongoDBUrl(connectionName);
     var client = new MongoClient(url);
     var server = client.GetServer();
     return server.GetDatabase(url.DatabaseName);
 }
开发者ID:jbrinkman,项目名称:Warehouse13,代码行数:7,代码来源:DB.cs

示例14: MongoDictionary

 public MongoDictionary(string connectionString, string databaseName, string collectionName)
 {
     var client = new MongoClient(connectionString);
     var server = client.GetServer();
     var database = server.GetDatabase(databaseName);
     entriesCollection = database.GetCollection<Entry>(collectionName);
 }
开发者ID:nikolaynikolov,项目名称:Telerik,代码行数:7,代码来源:MongoDictionary.cs

示例15: WellCastServerEngine

 public WellCastServerEngine()
 {
     //Get a Reference to the Client Object
     var mongoClient = new MongoClient( "mongodb://pelustondo:[email protected]:41140/wellcast");
     var mongoServer = mongoClient.GetServer();
     mdb = mongoServer.GetDatabase("wellcast");
 }
开发者ID:pabloelustondo,项目名称:WellCastServer,代码行数:7,代码来源:WellCastServerEngine.cs


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