mongodb-.net-driver

MongoDb 2.6.1 Error: 17444 - “Legacy point is out of bounds for spherical query”

ⅰ亾dé卋堺 提交于 2019-12-12 21:32:18
问题 After upgrading MongoDb to 2.6.1 in my System n i get sometimes the following error: Legacy point is out of bounds for spherical query ErrorCode 17444 Here: https://github.com/mongodb/mongo/blob/master/src/mongo/db/geo/geoquery.cpp#L73 I can see that this is raised by mongo db due to some invalid data. // The user-provided point can be flat. We need to make sure that it's in bounds. if (isNearSphere) { uassert(17444, "Legacy point is out of bounds for spherical query", centroid

MongoDB transaction

元气小坏坏 提交于 2019-12-12 20:56:31
问题 I have a method like below in C#: private void Save(object) { mongoCollection.Save(object); someotherRelationaldb.Save(object); } I have two DBs in which I have to save a object. One is MongoDB and another is a relational DB SQL server. If the Commit on Relational DB fails, I want to rollback the MongoDB save (I would like to maintain the order of save). What would be the proper way to rollback using the C# driver. 回答1: Yes, Now possible. For example Java; try (ClientSession clientSession =

How to Get the Server Address of the server that data is pulled from

大兔子大兔子 提交于 2019-12-12 18:34:41
问题 I know we have it in Java driver using cursor.getServerAddress(). However, I couldn't find any relevant call in C#. 回答1: Unfortunately, after digging a little deeper though through the C# driver source code (and the Java source code to see what it was doing), the actual server address that was used as part of the fetch is hidden away in the Enumerator as a private member ( _serverInstance ). In particular, it's hidden away in a class called the MongoCursorEnumerator . Unfortunately, there isn

C# - Generate “identity” like Id's with NoSQL (MongoDB)?

时光总嘲笑我的痴心妄想 提交于 2019-12-12 17:00:19
问题 I've been using MongoDB with C#, and have been using ObjectIds, then later GUIDs for my Entity Ids. I hate looking at these Id's, I think it's counter intuitive... I'd really like to be able to use integers or longs, like relational DBs Identity column. But I'm having a hard time finding a way to do it. If I use collection max + 1, that will lead to race conditions. I've read about using a Hi-Lo Generator algorithm, but how does that work? What if I have 10 app servers running the same code?

Is there a good open-source MongoDB Queue Implementation for the C# Driver

£可爱£侵袭症+ 提交于 2019-12-12 16:26:12
问题 Not that it wouldn't be easy (or fun) enough to write one, it makes sense not to re-invent the wheel so to speak. I've had a look around at various attempts, but I don't seem to have yet come across an implementation that supports these criteria; Simple queue OSS system with MongoDB persistence; C# Driver (official) based (so full POCO serialization) Tailable cursors rather than polling handles message timeout (GC correctly) handles consumer failure (ideally crash detecting re-insertion, but

Intermittent MongoDB Connection Issue: An attempt was made to access a socket in a way forbidden by its access permissions

て烟熏妆下的殇ゞ 提交于 2019-12-12 14:08:23
问题 I get the following exception thrown occasionally when trying to write documents to my collection. I am using MongoDB 3.0.7 hosted in mLabs. Our application is hosted in Azure (as a Web App) and I am using the C# 2.2.3 SDK. MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server. ---> System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions 191.235.xxx.xxx:54128 at System.Net.Sockets

IMongoCollection stats

徘徊边缘 提交于 2019-12-12 13:59:11
问题 I'm updating my code to use MongoDB new async API. One of my usages is to get the data size of the collection using : return Database.GetCollection("collectionName").GetStats().DataSize Is there any way to get a CollectionStatsResult object from IMongoCollection like MongoCollection.GetStats() did in the legacy API? The only option I see for now is to get a Json document and parse it : var jsonCommand = new JsonCommand<BsonDocument>("{collstats : \"collectionName\"}"); var jsonDocument =

How to apply BsonRepresentation attribute by convention when using MongoDB

徘徊边缘 提交于 2019-12-12 11:49:53
问题 I'm trying to apply [BsonRepresentation(BsonType.ObjectId)] to all ids represented as strings withoput having to decorate all my ids with the attribute. I tried adding the StringObjectIdIdGeneratorConvention but that doesn't seem to sort it. Any ideas? 回答1: Yeah, I noticed that, too. The current implementation of the StringObjectIdIdGeneratorConvention does not seem to work for some reason. Here's one that works: public class Person { public string Id { get; set; } public string Name { get;

Understanding WriteConcern in MongoDB C#

≡放荡痞女 提交于 2019-12-12 10:44:40
问题 I have been reading up on Write Concern in MongoDB. I understand that there are several levels that determine the level of guarantee that a write operation succeeded, with a performance trade-off for the higher you set this level. However, I am working in a C# environment, and I am trying to figure out how to use Write Concern there and what levels work best for certain situations. I already figured out how to collect the result of the check with a WriteConcernResult object, I am mainly

MongoDB commands from DOS or Windows

倖福魔咒の 提交于 2019-12-12 10:42:57
问题 I'm trying to copy 4 collections from one Mongo database to another on the same machine from C# program automatically. How do I do that? Is there a simple copy collection/database command in MongoDB C# driver? or do I have to use the Mongo shell by first typing the ./mongo ? If so how do I do that inside a MS-DOS command line window? Like ./mongo -copycollection from to ? 回答1: Use mongodump, Type: ./mongodump --db your_db_name --collection collection_name and then mongorestore: ./mongorestore