protected override Expression VisitIn(InExpression inExpression)
        {
            if (inExpression.Values is SqlParameterExpression spe)
            {
                var plist = queryContext.ParameterValues[spe.Name] as System.Collections.IList;

                // inExpression.Item

                // sqlFactory.a

                // var ce = sqlFactory.Constant(plist.Select(x => (object));

                List <object> list = new List <object>();
                foreach (var item in plist)
                {
                    list.Add(item);
                }

                var ce = sqlFactory.Constant(list, sqlFactory.GetTypeMappingForValue(list.FirstOrDefault()));

                // sqlFactory.MakeBinary(ExpressionType.or)



                return(inExpression.Update(inExpression.Item, ce, inExpression.Subquery));

                //var _relationalCommandBuilder = this.GetPrivateField<IRelationalCommandBuilder>("_relationalCommandBuilder");
                //_relationalCommandBuilder.Append(inExpression.IsNegated ? " NOT IN " : " IN ");
                //_relationalCommandBuilder.Append("(");
                //// _relationalCommandBuilder.Append(spe.Name);

                //// we need to expand our list here...
                //var prefix = spe.Name;

                //var plist = queryContext.ParameterValues[spe.Name] as System.Collections.IList;
                //int i = 0;
                //foreach(var pv in plist)
                //{
                //    var n = $"{prefix}_{i}";
                //    queryContext.AddParameter(n, pv);
                //    if (i != 0)
                //    {
                //        _relationalCommandBuilder.Append(", ");
                //    }
                //    _relationalCommandBuilder.AppendLine($"@{n}");
                //    i++;
                //}

                //_relationalCommandBuilder.Append(")");
                // return inExpression;
            }

            return(inExpression);
        }
Exemple #2
0
        protected override Expression VisitIn(InExpression inExpression)
        {
            var parentSearchCondition = _isSearchCondition;

            _isSearchCondition = false;
            var item     = (SqlExpression)Visit(inExpression.Item);
            var subquery = (SelectExpression)Visit(inExpression.Subquery);
            var values   = (SqlExpression)Visit(inExpression.Values);

            _isSearchCondition = parentSearchCondition;

            return(ApplyConversion(inExpression.Update(item, values, subquery), condition: true));
        }
Exemple #3
0
        protected override Expression VisitIn(InExpression inExpression)
        {
            Check.NotNull(inExpression, nameof(inExpression));

            var parentOptimize = _optimize;

            _optimize = false;
            var item     = (SqlExpression)Visit(inExpression.Item);
            var subquery = (SelectExpression)Visit(inExpression.Subquery);
            var values   = (SqlExpression)Visit(inExpression.Values);

            _optimize = parentOptimize;

            return(ApplyConversion(inExpression.Update(item, values, subquery), condition: true));
        }
        protected override Expression VisitIn(InExpression inExpression)
        {
            var canOptimize = _canOptimize;

            _canOptimize = false;
            _isNullable  = false;
            var item       = (SqlExpression)Visit(inExpression.Item);
            var isNullable = _isNullable;

            _isNullable = false;
            var subquery = (SelectExpression)Visit(inExpression.Subquery);

            isNullable |= _isNullable;
            _isNullable = false;
            var values = (SqlExpression)Visit(inExpression.Values);

            _isNullable |= isNullable;
            _canOptimize = canOptimize;

            return(inExpression.Update(item, values, subquery));
        }