示例#1
0
        protected virtual void ParseIn(MethodCallExpression expression)
        {
            var column = expression.Arguments[0] as MemberExpression;
            var value  = this.GetRightValue(expression.Arguments[1]);

            if (value is IEnumerable)
            {
                var val = value as IEnumerable;
                if (val.IsNullOrEmpty_())
                {
                    switch (__visitbinarytype)
                    {
                    case ExpressionType.And:
                    case ExpressionType.AndAlso: __sql.Append("(1<>1)"); break;

                    case ExpressionType.Or:
                    case ExpressionType.OrElse: __sql.Append("(1=1)"); break;

                    default: throw new NotImplementedException("暂时没实现 “{0}” 方法".F(__visitbinarytype.GetDescription_()));
                    }
                }
                else
                {
                    __sql.AppendFormat("({0} IN (@{1}))", GetColumnName(withTableName, Database, column), context.Parameters.Count);
                    context.Parameters.Add(val);
                }
            }
            else if (value is IGetBuilder)
            {
                var val = value as IGetBuilder;
                __sql.AppendFormat("({0} IN ({1}))", GetColumnName(withTableName, Database, column), val.GetSql(context.Parameters));
            }
        }