New Posts New Posts RSS Feed: Forcing Includes to come from cache
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Forcing Includes to come from cache

 Post Reply Post Reply
Author
alindzon View Drop Down
Newbie
Newbie
Avatar

Joined: 28-Jul-2010
Location: Toronto
Posts: 31
Post Options Post Options   Quote alindzon Quote  Post ReplyReply Direct Link To This Post Topic: Forcing Includes to come from cache
    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.
 
 
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
midnit View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22-Jun-2009
Location: Charlotte
Posts: 112
Post Options Post Options   Quote midnit Quote  Post ReplyReply Direct Link To This Post 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.



Edited by midnit - 20-Oct-2010 at 8:07am
Back to Top
alindzon View Drop Down
Newbie
Newbie
Avatar

Joined: 28-Jul-2010
Location: Toronto
Posts: 31
Post Options Post Options   Quote alindzon Quote  Post ReplyReply Direct Link To This Post 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.
 
 
Back to Top
midnit View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22-Jun-2009
Location: Charlotte
Posts: 112
Post Options Post Options   Quote midnit Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
alindzon View Drop Down
Newbie
Newbie
Avatar

Joined: 28-Jul-2010
Location: Toronto
Posts: 31
Post Options Post Options   Quote alindzon Quote  Post ReplyReply Direct Link To This Post 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.
 
 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down