Print Page | Close Window

Forcing Includes to come from cache

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2248
Printed Date: 29-Jul-2026 at 6:11am


Topic: Forcing Includes to come from cache
Posted By: alindzon
Subject: Forcing Includes to come from cache
Date Posted: 20-Oct-2010 at 6:10am

I think this is a simple question.  I am keeping the entire manufacturer list in cache, which is working perfectly when I query against it.

I have a product table which is NOT in cache, and I am accessing it one page at a time.
 
Every time I retrieve a page of products, I need to substitute the ManName for the ManID which is in the product file, for the view.  i.e. I show Manufacturer.ManName which is related by the ManID.
 
I want to compose the query in such a way that the ManName comes from cache and not from a join.
 
I have about 5 tables I am keeping in cache because they are constantly needed as a resource, and there is no need to keep hitting the database.
 
 



Replies:
Posted By: midnit
Date Posted: 20-Oct-2010 at 7:47am
Basically you have to do nothing.
 
If the navigation property's item is in cache it will wire it up for you. So remove your includes for the items you already have in cache. Thats assuming you mean you already queried and the data is cached in the same entitymanager.


Posted By: alindzon
Date Posted: 20-Oct-2010 at 7:51am
I tried that before I added the include, and not only was the database accessed, but it was accessed one entry at a time.  i.e. each row on the datagrid resulted in a single query to the database.
 
So I am afraid that did not work.
 
What I did in the xaml was I put in Manufacturer.ManName as the field to display.
 
 


Posted By: midnit
Date Posted: 20-Oct-2010 at 8:05am

Then perhaps you have something set so it wont use cache. It does work, we have over 13 joins that never happen due to the cached data already existing.



Posted By: kimj
Date Posted: 21-Oct-2010 at 10:46am
alindzon, since the Manufacturers are already in cache you don't need to, and actually shouldn't, use the Include when you query Products.   DevForce won't resolve part of the query from the database and part from cache - the entire query with the Include will go to the database if the entire query can't be satisfied from cache.   You'd use the Include when you didn't already have Products loaded, to bring in the object graph of Products and Manufacturers.


Posted By: alindzon
Date Posted: 21-Oct-2010 at 10:55am
But when I leave it off the include this is what happend even though its in cache.
I cam send you the entire trace, but here is the key piece.
SELECT
[Extent1].[ManID] AS [ManID],
[Extent1].[ManName] AS [ManName],
[Extent1].[Synonyms] AS [Synonyms],
[Extent1].[Display] AS [Display],
[Extent1].[Srch] AS [Srch],
[Extent1].[ProdCount] AS [ProdCount]
FROM [dbo].[Manufacturers] AS [Extent1]
WHERE 101424 = [Extent1].[ManID]
 
This occurs for each and every line in the gridview. 
 
But if I load up a manufacturer screen with just manufacturers in the grid there are NO database accessses at all.
 
 



Print Page | Close Window