Real World Sample of Context

Posts   
 
    
Devildog74
User
Posts: 719
Joined: 04-Feb-2004
# Posted on: 20-Jan-2006 14:55:20   

Does anyone or can anyone describe a real world implementation of the context that LLBLGen uses?

I am having a hard time figuring out what exactly it does and why exactly I might ever need to use it.

jeffreygg
User
Posts: 805
Joined: 26-Oct-2003
# Posted on: 20-Jan-2006 20:30:58   

I haven't really used them myself, but here's a shot:

SalesOrder->OrderLines->Products. I fetch all of the OrderLines for a given customer and make some changes (maybe I apply a discount) but do not save them yet. I then need to see the product data (maybe it's a different process that requires the product data attached). So, using a context I refetch the OrderLines and products and the context ensures that the OrderLines aren't overwritten (as they have changes) and the products are now attached to the orderlines.

I think that's right. wink

Jeff...

Devildog74
User
Posts: 719
Joined: 04-Feb-2004
# Posted on: 20-Jan-2006 20:38:15   

Oh ok, so its like a mini cache.

jeffreygg
User
Posts: 805
Joined: 26-Oct-2003
# Posted on: 20-Jan-2006 21:37:54   

Yes but by intention it's meant as a way of "uniquing" entities such that, when fetching data, the exact object reference in memory is always used to represent that entity.

Jeff...

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 21-Jan-2006 11:31:27   

It's for having the same entity object INSTANCE with the same entity data in a given context. In some situations it can be handy to have a single instance of an entity, related to a semantical context. You can have multiple semantical contexts in a single application, and can assure an instance is always the same instance through a context object.

You can use the context to pass a 'context' to a routine which will for example fetch entities again, though can use teh context to grab the same instances as they're used by the caller and therefore work with the same instance as the caller(which for example bound the instance to a set of controls).

Frans Bouma | Lead developer LLBLGen Pro