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.
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.