示例#1
0
        public void WhereIdMatchesGuids()
        {
            var database = TestConfiguration.GetDatabase();

            var dbEntityWriter   = new DbEntityWriter <WhereIdMatchesGuidModel>(database);
            var entityCollection = new DbEntityCollection <WhereIdMatchesGuidModel>
            {
                new WhereIdMatchesGuidModel {
                    Description = "1"
                },
                new WhereIdMatchesGuidModel {
                    Description = "2"
                },
                new WhereIdMatchesGuidModel {
                    Description = "3"
                },
                new WhereIdMatchesGuidModel {
                    Description = "4"
                }
            };

            dbEntityWriter.Write(entityCollection);

            var collection          = TestConfiguration.GetDatabase().GetCollection <WhereIdMatchesGuidModel>("WhereIdMatchesGuidModel");
            var underlyingQueryable = collection.AsQueryable();
            var queryable           = new MongoFrameworkQueryable <WhereIdMatchesGuidModel, WhereIdMatchesGuidModel>(underlyingQueryable);

            var entityIds = entityCollection.Select(e => e.Id).Take(2);

            var idMatchQueryable = LinqExtensions.WhereIdMatches(queryable, entityIds);

            Assert.AreEqual(2, idMatchQueryable.Count());
            Assert.IsTrue(idMatchQueryable.ToList().All(e => entityIds.Contains(e.Id)));
        }