C#MongoDB.Driver GetServer已经没了,现在怎么了?
发布时间:2020-12-16 05:31:01 所属栏目:百科 来源:网络整理
导读:从mongoDB.Driver文档( http://docs.mongodb.org/ecosystem/tutorial/getting-started-with-csharp-driver/) Get a Reference to a Server Object To get a reference to a server object from the client object,write this: var server = client.GetServer
从mongoDB.Driver文档(
http://docs.mongodb.org/ecosystem/tutorial/getting-started-with-csharp-driver/)
在最新版本中,GetServer方法已经消失了,但文档没有被更新,现在我们使用什么? 谢谢你的时间. 解决方法
GetServer是旧API的一部分.
要使用新的,闪亮的和异步准备好的API,只需直接在客户端上调用GetDatabase即可获取IMongoDatabase和GetCollection来获取IMongoCollection: var db = client.GetDatabase("HamsterSchool"); var collection = db.GetCollection<Hamster>("Hamsters"); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |