【c# – mysql连接的最佳驱动程序是什么?】教程文章相关的互联网学习教程文章

有没有人遇到过10Gen支持的c#驱动程序的问题【代码】

我看到了很多这些错误 “现有连接被远程主机强行关闭” 因为我从开源c#驱动程序切换到10Gen支持的驱动程序,所以在Mongo日志中.一旦发生此错误,我的网站就会无法响应.我觉得它与实现连接池的方式有关.请参阅下面的日志,我正在删除集合中的索引,删除所有项目,然后通过添加我想要的所有行来重新创建集合,然后重新编制集合索引.在完成所有操作后不久,我总是得到错误:’现有连接被远程主机强行关闭’[conn46] run command admin.$cmd {...

如何使用官方10gen C#驱动程序为地理值设置序列化选项?【代码】

考虑这个课程:public class Location {public Coordinates Geo { get; set; }public Location(){Geo = new Coordinates();}public class Coordinates{public decimal Lat { get; set; }public decimal Long { get; set; }} }我在集合集上有一个地理空间索引,如{Geo:“2d”}.不幸的是,驱动程序试图将lat / lon坐标存储为字符串,而不是数字,我得到一个错误,上面写着Tue Mar 15 16:29:22 [conn8] insert database.locations excepti...

哪个C#驱动程序用于Mongo?

我正在使用Mongo开始一个新项目,并想知道哪个C#驱动程序使用的一般共识是什么? 我倾向于NoRM(here)或官方司机(here). 在决定时使用哪些建议或意见以及考虑什么? 我意识到关于这个主题还有其他问题,但它们有点过时了.解决方法:NoRM有一些很酷的功能,但它不再被主动维护.当然可能会改变,但我宁愿选择正在积极开发的那个. 我将我的应用程序切换到官方C#驱动程序并且它很棒 – 它已经更新以利用1.8的所有新功能,并将继续升级以利用新...

无法使用MongoDB C#2.0驱动程序查询字典项【代码】

我有一个具有字典属性的类.[DataMember][BsonElement("QueriableParameters")]public Dictionary<string, string> QueriableParameters{get;set;}我正在使用新的MongoDB c#2.0驱动程序,但似乎无法做到这一点:var selectQuery1 = await collection.Find(s => s.QueriableParameters["UniqueLoanNumber"] == "3049793b-91eb-49d8-a5b4-7cbfd1a1bb3c").ToListAsync();我收到此错误说明:InnerException: System.InvalidOperationExce...

使用MongoDB C#驱动程序(v2.0)处理收集事件【代码】

使用新的MongoDB驱动程序(v2.0)非常困难.您在网络上找到的大多数示例仍然引用旧版驱动程序.至少可以说,Mongo官方网站上的The reference manual for v2.0是“简洁的”. 我试图做一个简单的事情:检测何时更改了一个集合,以便将C#事件转发到我的服务器应用程序. 为此,我找到了以下C#example(请参见下文),我正在尝试将其转换为新的API.using System; using System.Collections.Generic; using System.Linq; using System.Text; using ...

使用FindOneAndUpdateOptions类C#驱动程序在findAndModify中使用MongoDB映射属性’new’【代码】

我正在尝试为mongoDB实现getNextSequence函数,对此Link进行了解释我正在使用lattes C#驱动程序,但是我不确定如何在FindOneAndUpdateOptions中映射new:true属性 MongoDB代码function getNextSequence(name) {var ret = db.counters.findAndModify({query: { _id: name },update: { $inc: { seq: 1 } },new: true,upsert: true});return ret.seq; }C#代码public async Task<long> GetNextObjectSequenceAsync(string objectName){va...

MongoDB C#驱动程序检查身份验证状态和角色【代码】

这是我使用MongoDB身份验证机制登录MongoDB的代码.try {var credential = MongoCredential.CreateMongoCRCredential("test", "admin", "123456");var settings = new MongoClientSettings{Credentials = new[] { credential }};var mongoClient = new MongoClient(settings);var _database = mongoClient.GetDatabase("test");var collection = _database.GetCollection<Test>("book");var filter = new BsonDocument();var docume...

具有字典的MongoDB C#2.x驱动程序ElemMatch【代码】

我正在尝试使用ElemMatch使用2.2驱动程序在MongoDB中查找文档,但未成功.我收到如下异常:System.InvalidOperationException : The serializer for field‘EnabledForProduct’ must implement IBsonArraySerializer and provideitem serialization info.这是我的班级样子:public class Document {public string Id {get; set;}public Dictionary<Product, bool> EnabledForProduct { get; set; } } public enum Product {Product1...

MongoDB C#驱动程序在take(1)上快速运行,但在take(2)上运行缓慢【代码】

我第一次使用MongoDB C#驱动程序,发现性能出现了一些奇怪的结果.当我查询具有排序和.Take(1)的300万条记录的集合时,响应几乎是瞬时的(3毫秒).但是,当我对同一查询执行(2)时,它最多需要10秒.正确的索引就位,并且它是带有测试数据的非常简单的集合.MongoClient client = new MongoClient(); MongoServer server = client.GetServer();var database = server.GetDatabase("db_name"); var collection = database.GetCollection<MyType...

MongoDB C#.Net驱动程序2.0版基于位置的查询【代码】

这适用于1.9database.GetCollection<Places>("Places"); double maxDistanceInRadians = maxDistanceInMiles / 3959.0; var queryplaces = Query.WithinCircle("Loc", lon, lat, maxDistanceInRadians); MongoDB.Driver.MongoCursor cursor = places.Find(queryplaces).SetLimit(limit);如何使用2.0进行位置查询,Query(MongoDb.Drivers.Builder.Query)似乎不是2.0的一部分,这里是doc’s解决方法:检查此页:http://mongodb.github....

在C#中的管道中将$and用于mongodbgregate()函数驱动程序【代码】

我正在尝试使用C#中的mongodb聚合框架. 我希望能够在查询中放入$and.这是我要运行的mongodb查询-db.students.aggregate( {$match:{name:"mira", $and:[{date:{$gte:ISODate("2015-03-01T00:00:00")}}, {date:{$lte:ISODate("2015-04-01T00:00:00")}}]}, {$group:{"_id":"$subject", "$sum":"$marks"}} )我创建了与mongodb查询相对应的匹配项,但此处不正确,因为在括号中出现了编译器错误.我的C#代码如下-var match = new BsonDocume...

C#SQL连接驱动程序【代码】

SQL Connection对象将什么驱动程序连接到SQL Server以便运行查询? 如果我有以下代码:SQLConnection cn = new SqlConnection("server=ServerName;initial catalog=CorporateNA;Integrated Security=SSPI") cn.Open();SQL连接对象是否使用ODBC驱动程序SQL Server?我忍不住觉得这是一个愚蠢的问题,但是Google搜索该主题的努力毫无结果.当服务器上运行的应用程序连接到SQL Server时,我们遇到间歇性超时问题,而DBA询问它使用什么驱动...

MongoDB C#驱动程序和DateTime字段【代码】

我正在使用C#驱动程序将文档插入MongoDB集合,当我调试应用程序时,其中一个字段类型与DateTime我在“FrameTimeStamp”字段中看到服务器时间我将传递给Mongo,这是我的代码:FrameDocument frameDoc = new FrameDocument(); frameDoc.Frame = imageBA; frameDoc.EventCodeId = 1; frameDoc.SesionId = 1; frameDoc.FrameTimeStamp = DateTime.Now; frameDoc.ServerUserId = (int)toMongoDt.Rows[0]["ServerUserId"]; frameDoc.TraderI...

嵌入式MongoDB文档在使用C#驱动程序保存时未获取ID【代码】

当我有一个包含文档列表的根文档并且我保存/插入时,根文档总是从MongoDB获取一个ID,但列表中的文档没有,它们与ObjectId.Empty保持一致.我不确定我做错了什么或者这是否是预期的行为? 这是我正在尝试做的一个例子:鉴于课程:public class Foo {public ObjectId Id { get; set; }public string Name { get; set; }public IList<Bar> Bars { get; set; } }public class Bar {public ObjectId Id { get; set; }public string Name { ...

Mongodb c#驱动程序 – 将ID复制到插入的另一个字段【代码】

我正在使用.Net – mongodb c#driver for monngodb.插入文档时,我想将生成的[BsonId] ObjectId Id字段复制到文档中的另一个字段(复制值) 我可以运行Insert,它将生成密钥,然后运行update以将密钥复制到另一个字段,但这将使db处于“软”状态一段(短暂)时间. 是否有可能“原子地”这样做或者我使用mongodb错了吗?解决方法:如果您希望更新是原子的,那么您无法真正做到这一点. 我建议你做的不是让驱动程序设置Id,而是使用ObjectId.Ge...