public IReadOnlyQueryableSet Where()

in src/Core/Vipr/odataDemo.cs [2715:2791]


        public IReadOnlyQueryableSet<TSource> Where(System.Linq.Expressions.Expression<System.Func<TSource, bool>> predicate)

        {

            // Fix for DevDiv 941323:

            if (predicate.Body.NodeType == System.Linq.Expressions.ExpressionType.Coalesce)

            {

                var binary = (System.Linq.Expressions.BinaryExpression)predicate.Body;



                var constantRight = binary.Right as System.Linq.Expressions.ConstantExpression;



                // If we are coalescing bool to false, it is a no-op

                if (constantRight != null && 

                    constantRight.Value is bool && 

                    !(bool)constantRight.Value && 

                    binary.Left.Type == typeof (bool?) &&

                    binary.Left is System.Linq.Expressions.BinaryExpression)

                {

                    var oldLeft = (System.Linq.Expressions.BinaryExpression)binary.Left;



                    var newLeft = System.Linq.Expressions.Expression.MakeBinary(

                        oldLeft.NodeType,

                        oldLeft.Left,

                        oldLeft.Right);



                    predicate = (System.Linq.Expressions.Expression<System.Func<TSource, bool>>)System.Linq.Expressions.Expression.Lambda(

                        predicate.Type,

                        newLeft,

                        predicate.TailCall,

                        predicate.Parameters);

                }

            }                   



            var newSelector = _pascalCaseExpressionVisitor.Visit(predicate);



            DataServiceQuery query = CallLinqMethod(newSelector, true); 



            return new ReadOnlyQueryableSet<TSource>(

                query,

                _context);

        }