mongodb-.net-driver

Get all objects where a property matches a value nested in array

我的未来我决定 提交于 2019-12-10 22:24:52
问题 I have the following data table: { "_id" : ObjectId("value"), "owner" : "testuser", "date" : ISODate("2017-03-16T12:45:03.386Z"), "location" : "thuis", "venue" : "bijna thuis", "description" : "fghgfh", "completed" : false, "winnerName" : null, "subscriptions" : [], "interactions" : [ { "_id" : ObjectId("objectid"), "owner" : "testuser", "type" : "guess", "date" : ISODate("2017-03-06T12:13:10.049Z"), "answer" : false, "message" : "test 1" }, { "_id" : ObjectId("objectid"), "owner" : "testuser

mongodb c# driver - inheritance, mappings and serialization issue

杀马特。学长 韩版系。学妹 提交于 2019-12-10 21:37:58
问题 I have following class hierarchy for object stored in mongodb (I store only Branch objects and Entities in their graph) public class Branch : Aggregate { public IEnumerable<LocalizableText> Description { get; set; } public ObjectId PartnerId { get; set; } public double Latitude { get; set; } public double Longitude { get; set; } public string Timetable { get; set; } public IEnumerable<Discount> Discounts { get; set; } public IEnumerable<Category> Categories { get; set; } public IEnumerable

Has anyone been able to use successfully PredicateBuilder from albahari.com against MongoDB?

主宰稳场 提交于 2019-12-10 21:33:31
问题 I have the following code using the popular PredicateBuilder from albahari.com: var predicate = PredicateBuilder.False<Message>(); predicate.Or(p => p.Subject.Contains("a")); var test = this.MongoConnectionHandler.MongoCollection.AsQueryable().Where(predicate).ToList(); return this.MongoConnectionHandler.MongoCollection.AsQueryable().Count(predicate); The problem is that it doesn't return anything even though there are records in that column which contain the letter 'a'. Removing the

How to create “trigger” in MongoDB

╄→尐↘猪︶ㄣ 提交于 2019-12-10 20:30:04
问题 I would like of create a trigger where, to each subdocument inserted would increment in other collection a field, for generate a count of subdocuments that collection. I tried create a search using MapReduce, but for Milions of the Registries is very slow. Note: I use C#, but if you like show how to do in Bson, no problem. Extructure my collection public class Header { public Header() { Operation= new List<Operation>(); } public ObjectId Id { get; set; } public Int64 Code1 {get; set;} public

Dynamic Linq Predicate throws “Unsupported Filter” error with C# MongoDB Driver

a 夏天 提交于 2019-12-10 20:18:49
问题 I have been trying to pass in a dynamic list of Expressions to a MongoDB C# Driver query using Linq ... This method works for me with regular Linq queries against an ORM, for example, but results in an error when applied to a MongoDB query ... (FYI: I am also using LinqKit's PredicateBuilder) // // I create a List of Expressions which I can then add individual predicates to on an // "as-needed" basis. var filters = new List<Expression<Func<Session, Boolean>>>(); // // If the Region

allowDiskUse in Aggregation Framework with MongoDB C# Driver

浪尽此生 提交于 2019-12-10 17:33:12
问题 I would like to allowDiskUse:true. However I could not found any example which explain allowDiskUse enabling for MongoDB C# driver. How can I enable allowDiskUse in MongoDB C# driver? My sample code like that var pipeline = new[] { match, project, group, limit, sort, allow }; List<SMBMostInfluentialUser> result = db .GetCollection<SMBTwitterStatus>("TwitterStatus") .Aggregate(pipeline).ResultDocuments.Select(x => new User { Influence = Convert.ToDouble(x["Influence"]), User = new SMBUser(

mongoDB Rename embedded field

感情迁移 提交于 2019-12-10 17:26:48
问题 how do we rename embedded fields using C# with mongoDB ? An example of document Person would be: { Id: 1, LastName: "Smith", FirstName: "John", Orders: { Id: 1, Name: "Trousers" // I want to rename **Name** into **Something** } } With mongoDB syntax, it would be something like db.Users.update({}, {$rename:{"Orders.Name":"Orders.Something"}},true, true) Thanks. 回答1: Look at MongoDB.Driver.Builders.Update.Rename(string oldElementName, string newElementName) It returns an IUpdateQuery, which you

System.TimeoutException: A timeout occured after 30000ms selecting a server using CompositeServerSelector

跟風遠走 提交于 2019-12-10 17:21:44
问题 I have following application: application deployment diagram A - Application A is a .net wcf service hosted in IIS 7.5 using c# mongodriver 2.2.4 compiled in .net 4.5 B - Application B is a windows service application using mongodriver 1.11 compiled in .net 3.5 Both services are similar, service B is maintained for legacy systems and service A is under evolution. Both applications are hosted in same servers. (Windows Standard 2008 R2) This applications had been running for more than 1 year

MongoDB field-array searching (C#, How to?)

核能气质少年 提交于 2019-12-10 16:12:58
问题 Please tell me how make search by fields-arrays? I have some fields of type List<Int64> . For example first document has field-array with numbers [1,2,3,4] and second document has such field with numbers [4,5,6,7]. I want to find documents where my field consists 3 and 4 numbers, so it is first document. I am looking for examples that are based on official MongoDB C# driver;) Thank you very much!!! 回答1: You should use Query.All() . Code like this: var array = new List<int>() {3, 4}; var query

Manually supplying arguments to a MongoDB query to support collation feature (for case insensitive index)

微笑、不失礼 提交于 2019-12-10 15:56:02
问题 I have installed the current development version 3.3.11 in order to test the case insensitive index that is apparently supported according to https://jira.mongodb.org/browse/SERVER-90. I have tried this from a mongo shell and a simple test database and it does seem to work. Unfortunately, even though one specifies collation (and strength) during index creation, one must also specify the same collation params with .find in order to get case insensitive matches. If collation is omitted from the