ConnectionString
The standard URI connection scheme has the form: mongodb://[username:password@]host1:port1][/defaultauthdb]
三类连接方式
- Standalone
- Replica Set
- Sharded Cluster
Connection String Options
readConcern Options
mongodb://db0.example.com,db1.example.com,db2.example.com/?replicaSet=myRepl&readConcernLevel=majority
嵌套结构查询 Filter.ElemMatch
// MongoDB.Driver.FilterDefinition<TDocument>
var filterList = new List<FilterDefinition<Seckill>>();
filterList.Add(Filter.Where(t => t.BeginTime >= beginTime));
filterList.Add(Filter.ElemMatch(t => t.Items, s => s.ProductID == productID));
var filter = Filter.And(filterList);
return this.GetList(filter);
ConnectionTimeOut和SocketTimeOut的区别
来自 ConnectionTimeOut和SocketTimeOut的区别
一次完整的请求包括三个阶段:1、建立连接 2、数据传输 3、断开连接
SocketTimeOut就是数据传输超时。
如果与服务器(这里指数据库)请求建立连接的时间超过ConnectionTimeOut,就会抛 ConnectionTimeOutException,即服务器连接超时,没有在规定的时间内建立连接。
如果与服务器连接成功,就开始数据传输了。
如果服务器处理数据用时过长,超过了SocketTimeOut,就会抛出SocketTimeOutExceptin,即服务器响应超时,服务器没有在规定的时间内返回给客户端数据。
也就是说,ConnectionTimeOut是建立连接阶段超时,SocketTimeOut是数据传输阶段超时。
网友评论