Database Reference
In-Depth Information
Once the underlying query cache contains 800 or more query plans, a cache eviction process automatically kicks
off. Each minute, a sweeping process removes entries based upon a LFRU (least frequently/recently used) algorithm,
driven by hit count and age of the query.
Compiled queries are especially helpful in ASP.NET search page scenarios where parameter values may change,
but the query is the same and can be reused on each page rendering. This works because a compiled query is
parameterized , meaning that it can accept different parameter values.
13-7. Returning Partially Filled Entities
Problem
You have a property on an entity that is seldom read and updated. This property is expensive to read and update
because of its size. To improve performance, you want to populate this property selectively.
Solution
Let's say that you have a model like the one shown in Figure 13-9 .
Figure 13-9. A model with a Resume entity with a Body property that contains the entire text of the applicant's resume
We can simply avoid loading one or more properties on an entity by leveraging the SqlQuery() method from the
context to execute a SQL statement. The code in Listing 13-21 illustrates this approach.
Listing 13-21. Returning Partially Filled Entities Using Both eSQL and ExecuteStoreQuery()
using (var context = new EFRecipesEntities())
{
var r1 = new Resume
{
Title = "C# Developer",
Name = "Sally Jones",
Body = "...very long resume goes here..."
};
context.Resumes.Add(r1);
context.SaveChanges();
}
 
Search WWH ::




Custom Search