I am using EF6 and have a query using projection. I got the code from a question I asked here:
This code works perfectly, however it generates over 1200 lines of SQL and on first call, it is taking over 5 seconds to compile the query and 300ms to execute it, which is not acceptable. You can see what I mean here:
I used Glimpse to see what the SQL it was generating and interestingly noticed that if I remove comments, the SQL goes down to just 200 lines of code.
I decided to place the SQL into a stored procedure and although it returns the posts data correctly, the PostAuthor is not being populated.
I double checked and with the Linq query it is populated, but using
_context.Posts.SqlQuery(...)
the PostAuthor object is not being populated.
I also double checked the raw SQL query in SQL Server Management Studio and all the data is being returned, it is just not being populated when it returns.
Am I missing something? Is this a known issue?