예제 #1
0
        public void ShouldSupportInstanceClosures()
        {
            var comments = new Comment[0];
            var expected = comments.AsQueryable().Select(c => new CommentDto
            {
                HasUserPurchasedTheCourse = c.User.Purchases.Any(p => p.Items.Any(i => i.CourseId == c.CourseId)),
            });
            var actual = comments.AsQueryable().Select(c => ToCommentDto(c)).Decompile();

            AssertAreEqual(expected.Expression, actual.Expression);
        }
예제 #2
0
        public void ShouldFlattenTransparentExpressions()
        {
            var comments = new Comment[0];
            var expected = comments.AsQueryable().Select(c => new CommentDto
            {
                IsUserPurchaser = c.Purchases.Any(p => p.UserId == c.UserId)
            });
            var actual = comments.AsQueryable().Select(c => ToCommentDto(c)).Decompile();

            AssertAreEqual(expected.Expression, actual.Expression);
        }