mongodb-.net-driver

Storing composite/nested object graph

早过忘川 提交于 2020-01-01 12:16:34
问题 I am currently developing a document store in Mongo DB which contains a complete material breakdown of a specific item. The breakdown is calculated and contains a composite structure. The domain model: public interface IReagent { int ItemId { get; set; } int Quantity { get; set; } ConcurrentBag<IReagent> Reagents { get; set; } } public class Craft : IReagent { public int ItemId { get; set; } public int Quantity { get; set; } public int SpellId { get; set; } public int Skill { get; set; }

MongoDB: Calling Count() vs tracking counts in a collection

泪湿孤枕 提交于 2020-01-01 04:54:12
问题 I am moving our messaging system to MongoDB and am curious what approach to take with respect to various stats, like number of messages per user etc. In MS SQL database I have a table where I have different counts per user and they get updated by trigger on corresponding tables, so I can for example know how many unread messages UserA has without calling an expensive SELECT Count(*) operation. Is count function in MongoDB also expensive? I started reading about map/reduce but my site is high

Collection ID length in MongoDB

梦想的初衷 提交于 2020-01-01 04:25:10
问题 i am new to mongodb and stack overflow. I want to know why on mongodb collection ID is of 24 hex characters? what is importance of that? 回答1: Why is the default _id a 24 character hex string? The default unique identifier generated as the primary key ( _id ) for a MongoDB document is an ObjectId. This is a 12 byte binary value which is often represented as a 24 character hex string, and one of the standard field types supported by the MongoDB BSON specification. The 12 bytes of an ObjectId

Mongo Schema-less Collections & C#

余生长醉 提交于 2019-12-31 19:22:32
问题 I'm exploring Mongo as an alternative to relational databases but I'm running into a problem with the concept of schemaless collections. In theory it sounds great, but as soon as you tie a model to a collection, the model becomes your defacto schema. You can no longer just add or remove fields from your model and expect it to continue to work. I see the same problems here managing changes as you have with a relational database in that you need some sort of script to migrate from one version

Mongo Schema-less Collections & C#

杀马特。学长 韩版系。学妹 提交于 2019-12-31 19:22:10
问题 I'm exploring Mongo as an alternative to relational databases but I'm running into a problem with the concept of schemaless collections. In theory it sounds great, but as soon as you tie a model to a collection, the model becomes your defacto schema. You can no longer just add or remove fields from your model and expect it to continue to work. I see the same problems here managing changes as you have with a relational database in that you need some sort of script to migrate from one version

Mongo Schema-less Collections & C#

社会主义新天地 提交于 2019-12-31 19:22:08
问题 I'm exploring Mongo as an alternative to relational databases but I'm running into a problem with the concept of schemaless collections. In theory it sounds great, but as soon as you tie a model to a collection, the model becomes your defacto schema. You can no longer just add or remove fields from your model and expect it to continue to work. I see the same problems here managing changes as you have with a relational database in that you need some sort of script to migrate from one version

MongoDB performance issue: Single Huge collection vs Multiple Small Collections

老子叫甜甜 提交于 2019-12-31 17:26:14
问题 I tested two scenarios Single Huge collection vs Multiple Small Collections and found huge difference in performance while querying. Here is what I did. Case 1: I created a product collection containing 10 million records for 10 different types of product, and in this exactly 1 million records for each product type, and I created index on ProductType. When I ran a sample query with condition ProductType=1 and ProductPrice>100 and limit(10) to return 10 records of ProductType=1 and whose price

MongoDB performance issue: Single Huge collection vs Multiple Small Collections

谁都会走 提交于 2019-12-31 17:25:32
问题 I tested two scenarios Single Huge collection vs Multiple Small Collections and found huge difference in performance while querying. Here is what I did. Case 1: I created a product collection containing 10 million records for 10 different types of product, and in this exactly 1 million records for each product type, and I created index on ProductType. When I ran a sample query with condition ProductType=1 and ProductPrice>100 and limit(10) to return 10 records of ProductType=1 and whose price

Duplicate a mongodb collection

给你一囗甜甜゛ 提交于 2019-12-31 04:37:09
问题 What is a proper way to duplicate a collection in Mongodb on the same server using C#? MongoVUE has an option 'Duplicate collection', is there something similar for C#? 回答1: There isn't a built-in way to copy collections with the C# driver, but you can still do it pretty simply as: var source = db.GetCollection("test"); var dest = db.GetCollection("testcopy"); dest.InsertBatch(source.FindAll()); Note, however, that this won't copy any indexes from the source collection. The shell's copyTo

How to create Bson Document with Null value using C# official driver?

十年热恋 提交于 2019-12-30 18:09:05
问题 I have objects with 3 string fields Country, Province, City. They can contain null or some string name. I wanna query all data with the exact same values. For Example i need all data where City = null, Province = "WA", Country = "USA" I created BsonDocument: var lookup = new QueryDocument { {"GeoPosition.City", userLocation.City}, {"GeoPosition.Province", userLocation.Province}, {"GeoPosition.Country", userLocation.Country} }; But null field was thrown away and document looks like: {