Print Page | Close Window

Saving Cache using IEnumerable pDataRows

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=101
Printed Date: 29-Mar-2024 at 1:03pm


Topic: Saving Cache using IEnumerable pDataRows
Posted By: DocScooter
Subject: Saving Cache using IEnumerable pDataRows
Date Posted: 03-Jul-2007 at 5:28am
I think I would like to save a subset of the cache using the SaveEntitySet(ByVal pDataRows As IEnumerable, ByVal pFileName As string) overload.  But there is no clear example I have found in the tutorials or Developers Guide to develop the pDataRows in the DevForce context.  Maybe it's there and I just haven't found it or I don't know what to look for....
 
Can you post something that might enlighten me...please.  Thanks.
 
DocScooter



Replies:
Posted By: davidklitzke
Date Posted: 03-Jul-2007 at 10:17am
You can create a new PersistenceManager.  Then use ImportEntities to import the entities from one PersistenceManager to another.
 
Here is a code snippet which copies all changed Employees from one PersistenceManager to another.
 
       mPmLegacy = new PersistenceManager(true, "Legacy");
      mPmLegacy.ImportEntities(mPM.GetEntities<Employee>(DataRowState.Modified | DataRowState.Added | DataRowState.Deleted), MergeStrategy.PreserveChanges);
  


Posted By: DocScooter
Date Posted: 03-Jul-2007 at 1:02pm
Thanks, David.  So far so good.  Can I restore the EntitySet to any PersistanceManager or do I have to restore and then import?
 
What I am trying to do is store reference tables locally so that I will minimize network traffic since bandwidth and network traffic is an issue.  Once I have the tables locally I will just have to worry about the changes and that should be relatively easy to accomplish....
 
Thanks again and have a GREAT Independance Day!
 


Posted By: davidklitzke
Date Posted: 04-Jul-2007 at 8:16am
Scott,
 
Yes.  You can restore the EnitySet to any PersistenceManager.
 
David


Posted By: DocScooter
Date Posted: 04-Jul-2007 at 11:12am
Thumbs%20Up  Works Slick! 
 
I got a DB error when I disconnected until I used the call PersistanceManager.Disconnect()
 
 
Happy Fourth.....



Print Page | Close Window