Esempio n. 1
0
        public IExpressionTree <TClass> ParseTree <TClass>(params LambdaExpression[] lambdas)
        {
            var chains = lambdas.Select(lambda => ExpressionChainExtractor.AsExpressionChain(lambda));

            return(new ExpressionTree <TClass> {
                Children = ChainsToTree(chains).ToList()
            });
        }
        public void ExpressionToChain1()
        {
            Expression <Func <Department, User> > lambda = u => u.Head;
            var chain = ExpressionChainExtractor.AsExpressionChain(lambda);

            Assert.Equal(nameof(Department.Head), chain.Current.Name);

            Assert.True(new ExpressionEqualityComparer().Equals(lambda, chain.ToLambdaExpression()));
        }
        public void ExpressionToChain2()
        {
            Expression <Func <Department, IEnumerable <int> > > lambda = u => u.Head.Collaborators.Select(c => c.Id);
            var chain = ExpressionChainExtractor.AsExpressionChain(lambda);

            Assert.Equal(nameof(Department.Head), chain.Current.Name);
            Assert.Equal(nameof(User.Collaborators), chain.Next.Current.Name);
            Assert.Equal(nameof(User.Id), chain.Next.Next.Current.Name);

            Assert.True(new ExpressionEqualityComparer().Equals(lambda, chain.ToLambdaExpression()));
        }
Esempio n. 4
0
 public IExpressionChain <TClass> ParseChain <TClass, TProp>(Expression <Func <TClass, TProp> > lambda)
 => ExpressionChainExtractor.AsExpressionChain(lambda);
Esempio n. 5
0
 public IExpressionChain ParseChain(LambdaExpression lambda)
 => ExpressionChainExtractor.AsExpressionChain(lambda);