Exemple #1
0
        /// <summary>TODO The aa.</summary>
        public void Aa()
        {
            var client     = new MongoClient("mongodb://*****:*****@"http://stackoverflow.com/documentation/mongodb-csharp",
                        VisitPageIndex = 4
                    },
                    new Pages {
                        Url = @"https://github.com/", VisitPageIndex = 2
                    }
                }
            };

            collection.InsertOne(newItem);

            var result = IMongoCollectionExtensions.AsQueryable(collection).FirstOrDefault(s => s.SiteName == "Example");

            var update = Builders <Interactions> .Update.Set(s => s.SiteName, "New Example");

            IMongoCollectionExtensions.FindOneAndUpdate(collection, s => s.SiteName == "Example", update);
            IMongoCollectionExtensions.DeleteOne(collection, s => s.SiteName == "New Example");

            /*
             * from mongo driver
             * var result = Group(x => x.A, g => new RootView { Property = g.Key, Field = g.First().B });
             * result.Projection.Should().Be("{ _id: \"$A\", Field: { \"$first\" : \"$B\" } }"
             *
             * var result2 = IAggregateFluentExtensions.Unwind(IMongoCollectionExtensions.Aggregate(collection), e => e.Pages)
             *  .Group<Pages>(p => p.Pages.url, e => new Pages { Url = e.Key, VisitPageIndex = e.Count() });
             *
             * // var resurt = collection.Aggregate<BsonDocument>().Unwind<BsonDocument>(unwind)
             */
        }