zoukankan      html  css  js  c++  java
  • 在C#中mongohelper的初始化

    MongoClientSettings mongoSettings = new MongoClientSettings();
    TimeSpan t = new TimeSpan(100);
    mongoSettings.ConnectTimeout = t;//设置连接超时时长
    mongoSettings.MaxConnectionPoolSize = 2000;//设置连接池最大连接数
    MongoCredential cr = MongoCredential.CreateMongoCRCredential("数据库名", "用户名", "密码");//添加用户名、密码
    List<MongoCredential> credentials = new List<MongoCredential>();
    credentials.Add(cr);
    mongoSettings.Credentials = credentials;
    mongoSettings.Server =new MongoServerAddress("192.168.1.1",27017);//服务器地址
    mongoSettings.ReadPreference = new ReadPreference(ReadPreferenceMode.Primary);
    mongoClient = new MongoClient(mongoSettings);
    mongoServer = mongoClient .GetServer();
    mongoDataBase = mongoServer.GetDatabase(ConfigurationManager.ConnectionStrings[connectionString].ConnectionString.Split('|')[1]);
    mongoCollection = mongoDataBase.GetCollection(tableName);

  • 相关阅读:
    菜单范式
    PIC18F26K20
    单片机中串口通信模型
    STM8S103之GPIO
    STM8S103之ADC
    二叉树最近公共祖先
    全排列
    整数翻转
    完全二叉树节点个数
    二叉树的深度
  • 原文地址:https://www.cnblogs.com/zhenfeng/p/4222519.html
Copyright © 2011-2022 走看看