internal override Expression VisitMethodCall(MethodCallExpression m) { // We throw NotSupportedException when IsDisallowedExceptionForMethodCall() is true // or we have a method call on a non-entity type, for example c.MyCollectionComplexProperty.Select(...) if ((m.Object != null && (IsDisallowedExpressionForMethodCall(m.Object, this.context.Model) || !ClientTypeUtil.TypeOrElementTypeIsEntity(m.Object.Type))) || m.Arguments.Any(a => IsDisallowedExpressionForMethodCall(a, this.context.Model)) || (m.Object == null && !ClientTypeUtil.TypeOrElementTypeIsEntity(m.Arguments[0].Type))) { throw new NotSupportedException(Strings.ALinq_ExpressionNotSupportedInProjection(this.type, m.ToString())); } if (ProjectionAnalyzer.IsMethodCallAllowedEntitySequence(m)) { CheckChainedSequence(m, this.type); // allow selects for following pattern: // Orders = c.Orders.Select(o=> new NarrowOrder {...}).ToList(); return(base.VisitMethodCall(m)); } throw new NotSupportedException(Strings.ALinq_ExpressionNotSupportedInProjectionToEntity(this.type, m.ToString())); }
internal override Expression VisitMethodCall(MethodCallExpression m) { if ((m.Object != null && IsDisallowedExpressionForMethodCall(m.Object, this.context.Model)) || m.Arguments.Any(a => IsDisallowedExpressionForMethodCall(a, this.context.Model))) { throw new NotSupportedException(Strings.ALinq_ExpressionNotSupportedInProjection(this.type, m.ToString())); } CheckChainedSequence(m, this.type); if (ProjectionAnalyzer.IsMethodCallAllowedEntitySequence(m)) { // allow IEnum.Select and IEnum.ToList even if entity type. return(base.VisitMethodCall(m)); } if ((m.Object != null ? ClientTypeUtil.TypeOrElementTypeIsEntity(m.Object.Type) : false) || m.Arguments.Any(a => ClientTypeUtil.TypeOrElementTypeIsEntity(a.Type))) { throw new NotSupportedException(Strings.ALinq_ExpressionNotSupportedInProjection(this.type, m.ToString())); } return(base.VisitMethodCall(m)); }