示例#1
0
        public static Fetch <C> SelectMany <A, B, C>(this Fetch <A> self, Expression <Func <A, Fetch <B> > > bind, Expression <Func <A, B, C> > project)
        {
            var bindExpression = new BindProjectPair(bind, project);
            var newBinds       = self.CollectedExpressions.Append(bindExpression);

            return(new Bind <A, B, C>(newBinds, self));
        }
示例#2
0
        public static Fetch <B> Select <A, B>(this Fetch <A> self, Expression <Func <A, B> > f)
        {
            var isLet = LetExpression.IsLetExpression(f);

            if (!isLet)
            {
                return(new Select <A, B>(self, f));
            }

            Expression <Func <A, Fetch <A> > > letBind = _ => self;
            var letProject = LetExpression.RewriteLetExpression(f);
            var letPair    = new BindProjectPair(letBind, letProject);

            return(new Bind <A, B, B>(self.CollectedExpressions.Append(letPair), self)
            {
                IsLet = true
            });
        }