private SqlExpression VisitTupleAccess(MethodCallExpression tupleAccess)
        {
            int           columnIndex = tupleAccess.GetTupleAccessArgument();
            SqlExpression result;
            var           applyParameter = tupleAccess.GetApplyParameter();

            if (applyParameter != null)
            {
                if (compiler == null)
                {
                    throw Exceptions.InternalError(Strings.ExOuterParameterReferenceFoundButNoSqlCompilerProvided, OrmLog.Instance);
                }
                result = compiler.GetOuterExpression(applyParameter, columnIndex);
            }
            else
            {
                var queryRef = sourceMapping[(ParameterExpression)tupleAccess.Object];
                result = queryRef[columnIndex];
            }
            if (fixBooleanExpressions && IsBooleanExpression(tupleAccess))
            {
                result = booleanExpressionConverter.IntToBoolean(result);
            }
            return(result);
        }
 protected override Expression VisitMethodCall(MethodCallExpression mc)
 {
     if (mc.AsTupleAccess() != null)
     {
         var sourceIndex = mc.GetTupleAccessArgument();
         if (mc.GetApplyParameter() != null)
         {
             return(Expression.Call(leftTupleParameter, mc.Method, mc.Arguments[0]));
         }
         var name         = sourceColumns.Single(column => column.Index == sourceIndex).Name;
         var currentIndex = targetColumns[name].Index;
         return(Expression.Call(mc.Object, mc.Method, Expression.Constant(currentIndex)));
     }
     return(base.VisitMethodCall(mc));
 }
 /// <inheritdoc/>
 protected override Expression VisitMethodCall(MethodCallExpression mc)
 {
     if (mc.IsTupleAccess(tupleParameter))
     {
         var columnIndex    = mc.GetTupleAccessArgument();
         var outerParameter = mc.GetApplyParameter();
         if (outerParameter != null)
         {
             registerOuterColumn(outerParameter, columnIndex);
         }
         else
         {
             mappings.Add(columnIndex);
         }
         return(mc);
     }
     return(base.VisitMethodCall(mc));
 }
Example #4
0
        /// <inheritdoc/>
        protected override Expression VisitMethodCall(MethodCallExpression mc)
        {
            if (mc.IsTupleAccess(tupleParameter))
            {
                var columnIndex    = mc.GetTupleAccessArgument();
                var outerParameter = mc.GetApplyParameter();
                int newIndex       = outerParameter != null
          ? resolveOuterColumn(outerParameter, columnIndex)
          : mappings.IndexOf(columnIndex);

                if ((newIndex < 0 && ignoreMissing) || newIndex == columnIndex)
                {
                    return(mc);
                }
                return(Expression.Call(mc.Object, mc.Method, Expression.Constant(newIndex)));
            }
            return(base.VisitMethodCall(mc));
        }