Esempio n. 1
0
        public bool Save(object document)
        {
            if (document == null)
            {
                throw new ArgumentNullException("document");
            }

            var key = _metadata.GetDocumentId(document);

            return(Save(key, document));
        }
Esempio n. 2
0
        public void Load(BulkLoad load)
        {
            var tasks = new Task[load.Collections.Count];

            int i = 0;

            foreach (var pair in load.Collections)
            {
                var bulkCollection = pair.Value;
                var collectionName = pair.Key;
                var keys           = bulkCollection.Documents.Keys;

                var bsonIdArray = new BsonArray(keys);

                var collection = _mongoDatabase.GetCollection(bulkCollection.CollectionType, collectionName);

                tasks[i] = Task.Factory.StartNew(() =>
                {
                    MongoCursor cursor = collection.FindAs(bulkCollection.CollectionType, Query.In("_id", bsonIdArray));

                    foreach (var doc in cursor)
                    {
                        var id = _metadata.GetDocumentId(doc);
                        bulkCollection.Documents[id] = doc;
                    }
                });
                i++;
            }
            Task.WaitAll(tasks);
        }
Esempio n. 3
0
        public bool Save(object obj)
        {
            var key = _metadata.GetDocumentId(obj);

            return(Save(key, obj));
        }