private Type GetEnumType(BaseBlock block)
 {
     if (block is PropBlock)
     {
         PropBlock pExpr = (PropBlock)block;
         var       prop  = pExpr.Property;
         if (prop.IsDataProperty)
         {
             if (TypeFns.IsEnumType(prop.ReturnType))
             {
                 return(prop.ReturnType);
             }
         }
     }
     return(null);
 }
        public override void Validate(Type entityType)
        {
            var block = BaseBlock.CreateLHSBlock(ExprSource, entityType);

            if (!(block is PropBlock))
            {
                throw new Exception("The first expression of this AnyAllPredicate must be a PropertyExpression");
            }
            this.NavPropBlock = (PropBlock)block;
            var prop = NavPropBlock.Property;

            if (prop.IsDataProperty || prop.ElementType == null)
            {
                throw new Exception("The first expression of this AnyAllPredicate must be a nonscalar Navigation PropertyExpression");
            }


            this.Predicate.Validate(prop.ElementType);
        }
        public override void Validate(Type entityType)
        {
            if (Expr1Source == null)
            {
                throw new Exception("Unable to validate 1st expression: " + this.Expr1Source);
            }

            this._block1 = BaseBlock.CreateLHSBlock(Expr1Source, entityType);

            if (_op == Operator.In && !(Expr2Source is IList))
            {
                throw new Exception("The 'in' operator requires that its right hand argument be an array");
            }

            // Special purpose Enum handling

            var enumType = GetEnumType(this._block1);

            if (enumType != null)
            {
                if (Expr2Source != null)
                {
                    var et        = TypeFns.GetNonNullableType(enumType);
                    var expr2Enum = Enum.Parse(et, (String)Expr2Source);
                    this._block2 = BaseBlock.CreateRHSBlock(expr2Enum, entityType, null);
                }
                else
                {
                    this._block2 = BaseBlock.CreateRHSBlock(null, entityType, null);
                }
            }
            else
            {
                this._block2 = BaseBlock.CreateRHSBlock(Expr2Source, entityType, this._block1.DataType);
            }
        }