We take a lot of time on the first runs of our linq queries for EF. I was surprised to see the absence of differences after the anticipating views. I came across the following statement: stackoverflow
The presented generation only helps for "standard" queries (for example, when calling someObject.RelatedEnd.Load () or MyContext.SomeSetName (). This does not help for special queries with LINQ or ESQL for obvious reasons. Use CompiledQuery to optimize them.
When he says "for obvious reasons," I have to say, "Well, it’s not yet obvious to me." If I understand this correctly, he claims that Linq to SQL queries are not affected by the EF preliminary view.
I thought that entity representations are general comparisons between entities and tables and have nothing to do with any particular query. Is this a mistake?
I can see the huge amount of time that is used in the first run of our Linq to Entities queries, with much shorter times after that, so I assumed that views were created for the corresponding objects and tables. If this is not an EF view that can be pre-generated based on the entire first run time, then what is it?
So my question has three parts:
Are EF views created for each query, or do they simply link tables to objects regardless of the queries made?
Is the above statement that preliminary representations of EF do not affect the correctness of Linq's answers to EF? Do I need to use CompileQueries?
- What are the “obvious reasons” mentioned above?
Note. I wouldn’t even ask, but on the Internet there are several recommendations (including msdn) for previewing submissions if you use EF. This is the only place where I saw that he suggested that if you use Linq for Entities, then pregenerating is not relevant to your requests.
source share