Beispiel #1
0
        public async Task ReadsDocuments()
        {
            var petunia = await plantsCollection.FindOneAsync(
                new BsonDocument("name", "Petunia"), null);

            Assert.AreEqual("Store 47", petunia.Partition);
            var allPerennials = await plantsCollection.FindAsync(
                new BsonDocument("type", PlantType.Perennial.ToString()), null);

            Assert.AreEqual(2, allPerennials.Count());
            var allPlants = await plantsCollection.CountAsync();

            Assert.AreEqual(5, allPlants);
        }
Beispiel #2
0
        public async Task ReadsDocuments()
        {
            // :code-block-start: mongo-find-one
            var petunia = await plantsCollection.FindOneAsync(
                new { name = "Petunia" },
                null);

            // :code-block-end:
            Assert.AreEqual("Store 47", petunia.Partition);
            // :code-block-start: mongo-find-many
            var allPerennials = await plantsCollection.FindAsync(
                new { type = PlantType.Perennial.ToString() },
                new { name = 1 });

            // :code-block-end:
            Assert.AreEqual(2, allPerennials.Count());
            // :code-block-start: mongo-count
            var allPlants = await plantsCollection.CountAsync();

            // :code-block-end:
            Assert.AreEqual(5, allPlants);
        }
        public async Task ReadsDocuments()
        {
            // :code-block-start: mongo-find-one
            var petunia = await plantsCollection.FindOneAsync <Plant>(
                new BsonDocument("name", "petunia"), null);

            // :code-block-end:
            Assert.AreEqual(petunia.Partition, "Store 47");
            // :code-block-start: mongo-find-many
            var allPerennials = await plantsCollection.FindAsync <Plant>(
                new BsonDocument("type", PlantType.perennial), null);

            // :code-block-end:
            Assert.AreEqual(2, allPerennials.Count());
            // :code-block-start: mongo-count
            var allPlants = await plantsCollection.CountAsync();

            // :code-block-end:
            Assert.AreEqual(5, allPlants);
        }