Beispiel #1
0
        protected override Expression VisitNew(NewExpression node)
        {
            var elementType = node.Type;

            if (typeof(IEntity).IsAssignableFrom(elementType))
            {
                if (elementType.IsNotCompiled())
                {
                    elementType = EntityProxyManager.GetType(elementType);
                    return(Expression.New(elementType));
                }
            }

            return(base.VisitNew(node));
        }
        protected override Expression VisitNew(NewExpression node)
        {
            var elementType = node.Type;

            if (typeof(IEntity).IsAssignableFrom(elementType) && elementType.IsNotCompiled())
            {
                var contextType = _transContext.ContextType;
                elementType = EntityProxyManager.GetType(contextType, elementType);
            }

            if (elementType != node.Type)
            {
                var types     = node.Arguments.Select(s => s.Type).ToArray();
                var arguments = node.Arguments.Select(s => Visit(s));
                var consInfo  = elementType.GetConstructor(types);
                return(Expression.New(consInfo, arguments));
            }

            return(base.VisitNew(node));
        }