mongodb-.net-driver

How to use Auto Increment field in Mongo C# Driver without using eval?

拥有回忆 提交于 2020-06-12 07:31:17
问题 I'm using auto increment fild as discussed here. I can execute this example in Mongo Console, but how can I implement such a thing using c# driver ? db.products.insert({ "_id":getNextSequenceValue("productid"), "product_name":"Apple iPhone", "category":"mobiles" }) Is it possible to specify a function in the write operation ? I could call this function using Eval, but as it is being deprecated, I would like to find a solution without using it. 回答1: As exemplified here: var client = new

C# MongoDb Connect to Replica Set Issue

淺唱寂寞╮ 提交于 2020-05-27 06:03:22
问题 According to the mongodb website, I should be able to connect to a replica set if I just give it one member from the replica set: "The C# Driver is able to connect to a replica set even if the seed list is incomplete. It will find the primary server even if it is not in the seed list as long as at least one of the servers in the seed list responds (the response will contain the full replica set and the name of the current primary)." http://www.mongodb.org/display/DOCS/CSharp+Driver+Tutorial

SocketException when trying to send data to mongoDB on Azure

夙愿已清 提交于 2020-05-18 01:44:28
问题 I have a mongodb replica set hosted in a VM wjth Windows Server 2012 R2 on the Azure platform, my problem is that when I'm trying to insert data from an external client using the C# driver or even consulting them from a GUI client (mongoVUE, robomongo ...) I often get the following exception which permanently locks the program (even trying a Server.reconnect() does not resolve). No such host is known Type: System.Net.Sockets.SocketException Stack: at System.Net.Dns.GetAddrInfo(String name) at

RabbitMQ consumer as a windows service

被刻印的时光 ゝ 提交于 2020-02-27 11:59:27
问题 I have a rabbitmq consumer application implementing "publish/subscribe pattern in .net, which runs perfectly as a console application but when I deploy that as a windows service it does not seem to be saving the data into mongodb. protected override void OnStart(string[] args) { try { var connectionString = "mongodb://localhost"; var client = new MongoClient(connectionString); var factory = new ConnectionFactory() { HostName = "localhost" }; using (var connection = factory.CreateConnection())

storing a scanned (pdf,tiff,jpeg) file in MongoDB .

你离开我真会死。 提交于 2020-02-21 04:54:48
问题 I have to store a tiff(tag image file format) or pdf scanned file in mongodb that should be Text search able . like if we want to search "on base of text" it should be able to search . I am going to use .net mvc or java with mongodb . so how can i store this pdf file and then can retrieve from database . any suggestion will be appreciated . thanks 回答1: You can store files by using MongoDb GridFs as described in this question and extract texts from a PDF file by using some features those

Filter by date using an idObject

不问归期 提交于 2020-02-08 05:28:30
问题 Hí, this mongoDB query, filter documents by date using an idObject field. db.myCollection.find({_id:{$gt: ObjectId(Math.floor((new Date('1990/10/10'))/1000).toString(16) + "000 0000000000000"), $lt: ObjectId(Math.floor((new Date('2011/10/10'))/1000).toString(16) + "000 0000000000000")}}) How would you implement this using the C# driver? There's already any method to convert a date to idObject? Reference post: https://stackoverflow.com/a/13594408/2010764 回答1: One of the developers of the

MongoDb bulk operation get id

耗尽温柔 提交于 2020-02-04 11:05:57
问题 I want to perform bulk operation via MongoDb. How to get array of Ids that will be returned after it? Can i perform single-operation insert faster without using bulk ? Can you advise me some other approach ? I'm using C# mongoDb driver 2.0 and MongoDb v. 3.0.2 update: I found the following solution - save maximum ObjectId of mongo collection, db.col.find().sort({_id:-1}).limit(1).pretty() and do the same after insert So we will get the range of inserted documents, does it make a sense? 回答1:

MongoDb bulk operation get id

ぃ、小莉子 提交于 2020-02-04 11:04:06
问题 I want to perform bulk operation via MongoDb. How to get array of Ids that will be returned after it? Can i perform single-operation insert faster without using bulk ? Can you advise me some other approach ? I'm using C# mongoDb driver 2.0 and MongoDb v. 3.0.2 update: I found the following solution - save maximum ObjectId of mongo collection, db.col.find().sort({_id:-1}).limit(1).pretty() and do the same after insert So we will get the range of inserted documents, does it make a sense? 回答1:

Profiling the MongoDB database to see the executed queries

房东的猫 提交于 2020-02-04 07:34:45
问题 Is there a way to see the executed queries on MongoDB? I enabled profiling through the mongo.exe on windows with the following command: db.setProfilingLevel(2); This enables profiling and I can query the profile data with the following command for example: db.system.profile.find().limit(10).sort( { ts : -1 } ).pretty() However, this doesn't get me the executed queries. I know that I can also use the IMongoQuery.ToJson() method to see the query but I am using Linq queries with MongoDB C#

Using MongoDB shell commands on MongoDB 10Gen's driver

ε祈祈猫儿з 提交于 2020-02-03 05:39:05
问题 I want to simply execute pure MongoDB queries via MongoDb 10Gen's .net(c#) driver. For example . I want to use below command on driver db.people.update( { name:"Joe" }, { $inc: { n : 1 } } ); I am not sure how can i do this. I am not interested in how to do via high level api classes. 回答1: The C# driver (or any other driver) is not intended to "directly" run mongo shell commands. That's what the shell is for. What you need to do is translate the mongo shell commands into the equivalent C#