Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> Should Context be cleared before reloading entitycollection from DB?
 

Pages: 1
LLBLGen Pro Runtime Framework
Should Context be cleared before reloading entitycollection from DB?
Page:1/1 

  Print all messages in this thread  
Poster Message
Rosacek
User



Location:
CZ
Joined on:
18-Mar-2012 18:02:44
Posted:
133 posts
# Posted on: 15-May-2014 15:08:25.  
Hi,
I use context to have unique entity instance because of prefetch paths.

I am curious what is the best practice when I need to reload entitycollection (added to a context) from DB and a filter is changed between reloads.

For example in the first LoadData call, I want entities having .IsActive=TRUE
And then in the second call I want entities having .IsActive=FALSE

If I do not clear myContext, then I will have both active and inactive entities in context.
As I use context just to enforce uniqueness, I think, there is not necessary to call myContext.Clear while reloading data.

Code:
Public Sub LoadData(filter As IRelationPredicateBucket)
     Using adapter As New DataAccessAdapter
         myContext.Clear '???????? necesary?
         ecol.Clear()
         adapter.FetchEntityCollection(ecol, filter, 0, Nothing, prefetchPath)
     End Using
End Sub
  Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
8088 posts
# Posted on: 16-May-2014 07:48:41.  
As I see it, I don't think that you want to clear the Context in this case, you just have to clear the collection, which is done when you re-fetch it. The context keeps the entity instance 'data' in one place when you need to get it or to update it. You clear the Context when you want to reset the instance data control.

David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
 
Top
Rosacek
User



Location:
CZ
Joined on:
18-Mar-2012 18:02:44
Posted:
133 posts
# Posted on: 16-May-2014 11:23:21.  
Thanks Daelmo,
I have the same opinion, just needed confirmation.
  Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.