示例#1
0
        protected override Expression VisitNew(NewExpression expression)
        {
            if (_target != null)
            {
                return(base.VisitNew(expression));
            }

            _target = new TargetObject(expression.Type);

            var parameters = expression.Constructor.GetParameters();

            for (var i = 0; i < parameters.Length; i++)
            {
                _currentField = _target.StartBinding(parameters[i].Name);
                Visit(expression.Arguments[i]);
            }

            return(expression);
        }
示例#2
0
        protected override Expression VisitNew(NewExpression expression)
        {
            if (_target == null)
            {
                _target = new TargetObject(expression.Type);
                if (expression.Type.GetTypeInfo().HasAttribute <CompilerGeneratedAttribute>())
                {
                    // it's anonymous, and the rules are different
                    var parameters = expression.Constructor.GetParameters();

                    for (var i = 0; i < parameters.Length; i++)
                    {
                        var prop = expression.Type.GetProperty(parameters[i].Name);
                        _currentField = _target.StartBinding(prop);
                        Visit(expression.Arguments[i]);
                    }

                    return(null);
                }
            }

            return(base.VisitNew(expression));
        }
示例#3
0
 public SelectTransformer(IQueryableDocument mapping, TargetObject target, bool distinct)
     : base(distinct, target.ToSelectField(mapping))
 {
 }
示例#4
0
 public SelectTransformer(IQueryableDocument mapping, TargetObject target)
     : base(target.ToSelectField(mapping))
 {
 }