コード例 #1
0
        public async Task CanSortOnNestedProperty_WhenNotWrappingInNullChecks()
        {
            // This test ensures that relational sorting works with SQLite
            var context = await GetContextAsync();

            var usersQueryable = context.Users;
            var sortOption     = new SortOption
            {
                PropertyName = "FavoriteRestaurant.Street"
            };

            var orderedQuery = QueryableProcessor.ApplySorting(usersQueryable, sortOption, null, false);

            dynamic dynamicOrderedQuery = orderedQuery;

            var count = Queryable.Count(dynamicOrderedQuery);

            // It should have all three results
            Assert.Equal(3, count);
        }
コード例 #2
0
        public async Task CanSortOnNestedProperty_WhenWrappingInNullChecks()
        {
            // This test ensures that relational sorting works with SQLite
            var context = await GetContextAsync();

            var usersQueryable = context.Users;
            var sortOption     = new SortOption
            {
                PropertyName = "FavoriteRestaurant.Street"
            };

            var orderedQuery = QueryableProcessor.ApplySorting(usersQueryable, sortOption, null, true);

            dynamic dynamicOrderedQuery = orderedQuery;

            var count = Queryable.Count(dynamicOrderedQuery);

            // It should only have two results since the added null checks remove
            // the user with the missing FavoriteRestaurant
            Assert.Equal(2, count);
        }
コード例 #3
0
        public async Task CanSortOnPropertyFromBaseClassWhenProjectedToDerivedClass()
        {
            var context = await GetContextAsync();

            var usersQueryable = context.Users
                                 .Select(u => new User
            {
                Name = u.Name
            });

            var sortOption = new SortOption
            {
                PropertyName = nameof(User.Name)
            };

            var orderedQuery = QueryableProcessor.ApplySorting(usersQueryable, sortOption, null);

            dynamic dynamicOrderedQuery = orderedQuery;

            var count = Queryable.Count(dynamicOrderedQuery);

            Assert.Equal(3, count);
        }
コード例 #4
0
        public void ArgumentNullExceptionOnNullQueryable()
        {
            var sortOption = new SortOption();

            Assert.Throws <ArgumentNullException>("queryable", () => QueryableProcessor.ApplySorting(null, sortOption, null));
        }
コード例 #5
0
        public void ArgumentNullExceptionOnNullQueryable()
        {
            var queryOptions = new QueryOptions();

            Assert.Throws <ArgumentNullException>("queryable", () => QueryableProcessor.ApplySorting(null, queryOptions));
        }