Tagged Questions
3
votes
1answer
930 views
Element 'Id' does not match any field or property of class
I got the result from collection in Mongo , the structure is the same as this
[DataContract]
public class Father
{
[BsonId]
[DataMember]
public MongoDB.Bson.ObjectId _id { get; ...
2
votes
1answer
413 views
Mongodb c# driver FindAll with setFields and AsQueryable
Using MongoDB C# driver, seems that I'm unable to get the data by AsQueryable with setFields and Where condition only by mongo query. I fetched documents by this code
var query = ...
2
votes
1answer
284 views
How to find newest document in Mongo Collection (C#)
How do I find the most recent document in a MongoCollection? Currently I'm doing the following, but it seems to be returning the same value regardless:
...
2
votes
1answer
236 views
How do I properly bridge asp mvc 3 and a mongodb database?
I'm a beginner trying to teach myself web development from scratch so I can build the serious social network startup I see in my mind. I've chosen to work with asp.net MVC3 in C# with mongodb. Now, ...
2
votes
1answer
349 views
Managing changes in class structure to be consistent with mongodb collection
We are using mongodb with c#. We are trying to figure out a way to keep our collection consistent seamlessly. Right now, if a developer make any changes to the class structure(add a field or change ...
2
votes
1answer
136 views
Expected update behavior on re-saving while using MongoDB's official C# driver
Trying to understand the expected behavior on re-saving a existing document (from a 3+ level object graph) that was previously saved. Is an update applied to only the top level fields or does it ...
1
vote
1answer
105 views
InvalidCastException: ConstantExpression to LambdaExpression in MongoDB Driver
How can I wrap this into a reusable expression that I can use elsewhere in my code?
nv => nv.a == nv2.a
I've tried doing this, but seems to return a ConstantExpression rather than a ...
1
vote
1answer
160 views
Is there a good open-source MongoDB Queue Implementation for the C# Driver
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 ...
1
vote
1answer
159 views
How to update a record in MongoDB with 2 different classes without deleting other fields
Let's say I have two classes like below:
public class Class1
{
....
public int CityId {get;set;}
public string CityName {get;set;}
public ObjectId _id {get;set;}
}
public class Class2 : Class1
{
...
1
vote
1answer
282 views
Grouping by multiple values when using dynamic linq and fluent mongo causes a malformed map-reduce emit statement
I'm using dynamic link to run mapreduce queries and I'm running into a problem when trying to group by multiple values. Check this out:
This works fine:
var query =
...
1
vote
1answer
403 views
Merge two collections in mongodb using c#
I have two collections in mongodb.I am retreiving data from two collections independently working gud.But when I am implementing paging using skip and take methods I am getting data from both the ...
1
vote
1answer
1k views
MongoDb BsonClassMap
I'm new to MongoDb and I'm currently using the CSharp drivers (version 1.2). My problems occur when using BsonClass map. Below is the code I'm tring to execute. I've simply defined a custom type I'd ...
1
vote
1answer
410 views
cannot edit any value in this datagridview
i have a datagridview bould on a list from Mongodb. however i cannot edit the grid. I dunno why its like that?
var connstr = "Server=localhost:27017";
mongo = new Mongo(connstr);
...
0
votes
1answer
23 views
How to speed up typed builders in 10gen official MongoDB C# driver?
Profiling my application I've discovered an unpleasant fact what typed Upadte<> (and Query<>) builder evaluates lambda expressions on each request, consuming a lot of CPU. You will gain several ...
0
votes
1answer
25 views
Use GuidRepresentation.Standard with MongoDB
I am implementing a custom IBsonSerializer with the official MongoDB driver (C#). I am in the situation where I must serialize and deserialize a Guid.
If I implement the Serialize method as follow, ...
0
votes
1answer
31 views
Find documents that contain search string in any field
I'm trying to find the best way to make MongoDb look for a specific value in all document's fields. For example if I have two documents:
{
field1: "value1"
field2: "value2"
}
and
{
...
0
votes
1answer
17 views
write data to capped collection is too slow
I noticed that someone has asked this question at here(slow inserts into a capped collection?),but no any best answer.
the blow log is my capped collection insert operation.
Tue Apr 30 13:12:19.172 ...
0
votes
1answer
15 views
(mongodb) Fetching a bson object within a bson object using csharp
I have a collection which contains documents like:
{
field1: {subfield1:{ssfield1:5,ssfield2:6},subfield2:6},
field2: 1,
...
}
I'd like to fetch only the subfield, but I'm not sure how to get ...
0
votes
1answer
46 views
MongoDb Query doesn't return all of the time
I have a very simple query that I am running against Mongo using the official C# driver 1.8 that only returns from performing the query about 50% of the time. I have a unit test and if I run the ...
0
votes
1answer
99 views
Mongodb: Elegant way to turn Aggregation Framework result into POCO
To make this short and understandable, http://mikaelkoskinen.net/mongodb-aggregation-framework-examples-in-c/ shows somewhat of what I am trying to accomplish. This "ToDynamic" call breaks on a ...
0
votes
1answer
137 views
MongoDb c# Linq query and return a collection's child objects
Say I have a typical customers and orders scenario. I have a collection of customers and each customer document has a list of orders. Now I want to query the customers where the order date is within ...
0
votes
1answer
77 views
The optimal way to load referenced entities from other collections from C# and MongoDb
In my Mongo database I have two collections, let's they are A and B.
Entities of type A has, for example, a list of ids of entities of type B. This list is just a list of strings, where each string is ...
0
votes
1answer
73 views
Get MongoDB server time from the C# driver
how do I get MongoDB current server time from the C# driver?
In case I have multiple shards and replica set, does monogo allow their time to be out synch?
As for case 2, if the several servers time ...
0
votes
1answer
122 views
How to access nested array properties with strongly typed query builders in mongodb
Trying to figure out how to access nested array properties when using the strongly typed query builders for mongodb in c#. Lets say I have the following classes:
public class V {
public Guid _id ...
0
votes
1answer
62 views
Filtering set of images from MongoDB
I have written some codes to store image files in MongoDB. Now I want to filter and retrieve some images from the mongoDB. I want to filter out some images which has some set of characters on the ...
0
votes
1answer
71 views
Mongodb query for subchild
I have monogodb data struture as below:
{
"_id" : ObjectId("512c4c468c08631ff0dbb02c"),
"ReferenceNumber" : "MongoDb",
"Title" : "Shashi",
"CreatedUserId" : ...
0
votes
1answer
28 views
How to get a number of documents starting by a certain document in mongodb
Let's say, in mongo db, I have a collection like this:
{_id: "A", Value: "1"}
{_id: "B", Value: "2"}
{_id: "C", Value: "3"}
{_id: "D", Value: "4"}
{_id: "E", Value: "5"}
{_id: "F", Value: "6"}
{_id: ...
0
votes
1answer
49 views
How store objects in MongoDb without assembly fully qualified name
I store item that contains fields like Dictionary
In mongo this field has _t = System.Collections.Generic.Dictionary`2[System.String,[Namespace.MyType, Namespace, Version=1.0.0.0, Culture=neutral, ...
0
votes
1answer
63 views
How to implement this in MongoDB?
I migrated my SQL Server DataBase to MongoDB.Now I have a problerm.
select * from AgentStatus a,
(select Max(TimeStamp) as TimeStamp,ExtNo
from AgentStatus
group by Extno) b
where a.[TimeStamp] = ...
0
votes
1answer
72 views
MongoDB Aggregation using official C# driver?
I'm using the official C# driver.Have no idea to implement this:
Select MAX(TimeStamp) as MaxTimeStamp, ExtNo From AgentStatus Where TimeStamp>=@begin and TimeStamp <=@end Group By ExtNo
Any ...
0
votes
1answer
65 views
How do I update a mongodb array
How can I update update list of picture?
Model:
public class Test
{
[BsonId]
public string Id { get; set; }
public string Name { get; set; }
public ...
0
votes
1answer
78 views
Query MongoDB with object as parameter, not just a particular field equality or whatever
Is it possible to query MongoDB, but using a C# object (which may be partially populated) as the query parameter?
I.e. find all foo in collection where they are partially or more equal to my ...
0
votes
1answer
125 views
Mongo DB C# code using 2 level , 3 level and 4 level of array
I have to update in C# code using MongoDB. Here I had implement 2nd level array of update in below (subBranchindex is taken in a generic list object):-
for (var index = 0; index < ...
0
votes
1answer
202 views
update in a nested array using C# Driver in MongoDB
Here is my exact schema:
{
"_id" : ObjectId("4fb4fd04b748611ca8da0d45"),
"Name" : "Agent name",
"City" : "XXXX",
"BranchOffice" : [{
"_id" : ...
0
votes
1answer
95 views
Mongodb exception failed to get next data vb.net
I have a program to get data from database mongodb but I failed to get next data
This code
Dim listOfBusiness = New Generic.List(Of Business)
Dim mongo As MongoServer = ...
1
vote
0answers
68 views
How to force mongo to store members in lowercase?
I have a collection of BsonDocuments, for example:
MongoCollection<BsonDocument> products;
When I do inserts into the collection, I want the member name to always be lowercase. After reading ...
1
vote
0answers
623 views
C# Mongodb get cursor count
I am trying to find out if a document exists in a collection using the code below. Whenever the query doesn't find any documents I get a StackOverflowException. What am I doing wrong with this?
...
0
votes
0answers
11 views
update with calculated values
I am trying to do create an update statement that uses a calculated value and I can see how you can use the aggregation framework to do a query but how about the update. I'm doing it in c#. I need the ...
0
votes
0answers
55 views
Suggestion for searching content in MongoDB in MVC Ajax application
Our database stores photo albums and photos.
Each album has title, tags, description.
Each photo has title, tags and description.
All I want is the ability to show 5 search results as soon as the ...
0
votes
0answers
27 views
'Cursor not found' error when use a Tailable Cursor with NoCursorTimeout
I created a capped collection with a 50M default size. More recently, I noticed that I get a Cursor not found error when a capped collection storage size goes over 50M. I'm not sure what reason causes ...
0
votes
0answers
54 views
How to test that a string field in a MongoDB document is not empty?
I am trying to get the number of documents that have a field with an empty string. This field, lets call it "Field_One" is present in all documents (so, to be clear, I am not trying to find if the ...
0
votes
0answers
137 views
MongoDb query search text
Below is my Mongodb data structure. i want a query in c# where i can search the item depending upon the customerid,protofolio and metatags.
{
"_id" : ...
0
votes
0answers
50 views
MongoDB Driver throwing error and no help found
I am recently facing this cryptic error from MongoDB error which I did not see before. I have this piece of code which is basically a test case and It does a find & modify on some MongoDB document ...
0
votes
0answers
650 views
Multiple actions were found that match the request Error WEB API MongoDB c#
Im fairly new to ASP.NET MCV 4 as well as Mongo DB and trying to build web API.
I thought I had finally got it right but when I start the app and enter: http://localhost:50491/api/document into my ...
0
votes
0answers
223 views
Mapping Complex Objects with MongoDB
Given an arbitrarily complex hierarchy of objects, e.g.
class ComplexObject
{
public ICollection<A> Components { get; set; }
...
}
class A
{
public ICollection<int> Values{ ...
0
votes
0answers
122 views
Join multiple collections on multiple keys using map reduce in Mongo DB.
I know a way to join multiple collections using a same key, and I thinks its not possible to join multiple collections on multiple keys but wondering anyone know a way to do it.
Lets say I have a ...
0
votes
0answers
143 views
Search dynamic field in mongo
I need to return a result from my Person in List form.
Below is my MongoDB structure :
Person
{ "Name" :
"Age" :
"Childs" : {
"Name" :
"Age" :
"Childs" : {
// Repeat ...
0
votes
0answers
97 views
MongoDB C# driver crash on First() call
I am having issues with the latest MongoDB C# driver (v1.4.2.4500) crashing when I query this document:
{
"_id" : "4fdfe705b48c6b24dcab994a",
"CreatedDate" : new Date("6/18/2012 19:42:13"),
...
0
votes
0answers
94 views
Mongo DB connection always fails on first attempt
I have the following code. Always it throws an exception "Unable to connect to the primary member of the replicaset" on the line 3. I replaced the third line with ...
0
votes
0answers
291 views
Nested queries in MongoDb using official C# driver
I need to query something like this:
<Parent>
<Child1> </Child1>
<Child2>
...