在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
1 MongoClientSettings mongoSettings = new MongoClientSettings(); 2 TimeSpan t = new TimeSpan(100); 3 mongoSettings.ConnectTimeout = t;//设置连接超时时长 4 mongoSettings.MaxConnectionPoolSize = 2000;//设置连接池最大连接数 5 MongoCredentials credentials = MongoCredentials.Create("用户名", "密码");//添加用户名、密码 6 mongoSettings.DefaultCredentials = credentials; 7 mongoSettings.Server =new MongoServerAddress("192.168.1.1",27017);//服务器地址 8 mongoSettings.ReadPreference = new ReadPreference(ReadPreferenceMode.Primary); 9 mongoClient = new MongoClient(mongoSettings); 10 mongoServer = mongoClient .GetServer(); 11 mongoDataBase = mongoServer.GetDatabase(“数据库名称”); 12 mongoCollection = mongoDataBase.GetCollection(tableName); |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论