We're updating the issue view to help you get more done. 

Invalid query model generated when Select is projecting a new object without any property assignment


Query like this

The generated the SelectClause has ConstantExpression of type `PostDTO` even though the original query has NewExpression with ctor. Which means it returns the same object for every element instead of providing new instance. It works fine if there are any object initializer to PostDTO.


Michael Ketting
April 18, 2017, 2:16 PM

See also: https://github.com/aspnet/EntityFramework/issues/7983

Thanks for the reduced repro sample. It was a great tool to help focus on the core issue and much appriciated!

This issue occurs because to the query parser, the ctor-expression is not dependent on the query's result and is therefor partially evaluated. In re-linq, we have decided on an opt-out approach regarding which expressions should be partially evaluated even when they are not dependent on the query's result. Opt-outs can be defined by injecting a custom IEvaluatableExpressionFilter in QueryParser:

If I remember this correctly, EntityFramework already uses the IEvaluatableExpressionFilter and only requires additional rules, this time for the IsEvaluatableNew(...) method. I'm closing this for now, please let me know if there's any additional reason to re-open the issue.


Michael Ketting


User known




Fix versions

Affects versions