CacheResultset but ignore a collection in a prefetch path?

Posts   
 
    
neilx
User
Posts: 267
Joined: 02-Nov-2007
# Posted on: 01-Jun-2014 19:03:34   

4.1.14.0327 SD.LLBLGen.Pro.DQE.SqlServer.dll 4.1.14.0327 SD.LLBLGen.Pro.ODataSupportClasses 4.1.14.0327 SD.LLBLGen.Pro.ORMSupportClasses.dll 4.1.14.0327 SD.LLBLGen.Pro.ORMSupportClasses.Web.dll

DotNet 4.0 vs2013 project Adapter template SQL Server 2008 R2

I have started to use the CacheResultset command on Linq collections. This works well. One of the paths is a collection of user updated answers and comments to the top entity collection.

Is there a way to exclude this entity collection from the cache?

Alternatively, can I simply leave the answers prefectch path out of the object and get it separately. The reattach it to the collection so it gets filtered appropriately?

Here is a short version of the code. The RegulationBase collection changes once a month. The answers change dynamically:

var q = metaData.RegulationBase.WithPath(a=>a.Prefetch<AnswerRegulationEntity>(b => b.AnswerRegulation));

Note that the full Linq is very complex and takes 1.5 to 2 seconds to fetch on a good day. This is why I want to cache the parts that don't change much.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 02-Jun-2014 06:34:18   

AFAIK, You cannot separate the cache behavior between the root and the PrefetchPath (ref...).

Yes, you could fetch the sub-collection separately and sync them manually (i.e. write your own routine that clean old entities and put there the new ones).

David Elizondo | LLBLGen Support Team
neilx
User
Posts: 267
Joined: 02-Nov-2007
# Posted on: 02-Jun-2014 11:37:28   

daelmo wrote:

... Yes, you could fetch the sub-collection separately and sync them manually (i.e. write your own routine that clean old entities and put there the new ones).

Yes. That works. Thanks for the suggestion.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39861
Joined: 17-Aug-2003
# Posted on: 02-Jun-2014 14:47:57   

We'll see what we can do before v4.2 RTMs (currently in beta wink ). It will be along the lines of .NoCaching() or something on a prefetch path node. No promises, but as I can imagine writing merge code is not what you want to do, we'll do our best to find a solution for this before RTM.

Frans Bouma | Lead developer LLBLGen Pro
neilx
User
Posts: 267
Joined: 02-Nov-2007
# Posted on: 02-Jun-2014 19:09:10   

Otis wrote:

We'll see what we can do before v4.2 RTMs (currently in beta wink ). It will be along the lines of .NoCaching() or something on a prefetch path node. No promises, but as I can imagine writing merge code is not what you want to do, we'll do our best to find a solution for this before RTM.

Happy to beta test for you!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39861
Joined: 17-Aug-2003
# Posted on: 11-Jun-2014 10:56:53   

This is implemented in the next build of v4.2 beta


var q2 = (from c in metaData.Customer
            where c.Country == "Germany"
            orderby c.CustomerId
            select c)
            .WithPath(cp => cp.Prefetch<OrderEntity>(c => c.Orders)
                    .OrderBy(o => o.OrderId)
                    .NoCaching()
                    .SubPath(op => op.Prefetch<OrderDetailEntity>(o => o.OrderDetails)
                        .OrderBy(od => od.OrderId)))
        .CacheResultset(10, tag);

The '.NoCaching()' call on a path node (other prefetch path api using path edge and queryspec have the same mechanism implemented) signals the path that that node shouldn't inherit its parents' caching directive and thus be fetched from the db. Child nodes from that node again inherit the caching directive from the root so the above tree will read customers and order details from the cache and will always fetch orders from the db.

So in your situation you then should be able to specify on the leaf nodes of the tree using NoCaching() that they should be read from the DB always, and the rest is read from the cache simple_smile

The NoCaching() flag makes the node not use caching at all so the resultset is never even added to the resultset cache, it's as if you didn't specify caching.

Frans Bouma | Lead developer LLBLGen Pro
neilx
User
Posts: 267
Joined: 02-Nov-2007
# Posted on: 11-Jun-2014 14:55:02   

Terrific. Thanks. I'll get the beta asap this week and try it.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39861
Joined: 17-Aug-2003
# Posted on: 11-Jun-2014 18:59:28   

neilx wrote:

Terrific. Thanks. I'll get the beta asap this week and try it.

The build it's in hasn't been released yet, it's likely uploaded monday next week simple_smile

Frans Bouma | Lead developer LLBLGen Pro