Print Page | Close Window

Persistence Manager - HasChanges

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=230
Printed Date: 07-Jun-2025 at 12:59am


Topic: Persistence Manager - HasChanges
Posted By: Customer
Subject: Persistence Manager - HasChanges
Date Posted: 12-Jul-2007 at 4:46pm

When the PersistenceManager.HasChanges is true,

1)       Can the PM tell me which entities it thinks has changes?

2)       For a specific entity which “HasChanges”, can the PM tell me which columns it thinks has changed?




Replies:
Posted By: IdeaBlade
Date Posted: 12-Jul-2007 at 4:48pm
     (1)                 You can get the specific entities by asking for all entities that have a DataRowState of Added, Deleted, or Modified.  For example, you can get all Employees with changes with this one line of code.

                  mEmployees = mPM.GetEntities<Employee>

                      (DataRowState.Added | DataRowState.Deleted | DataRowState.Modified);;

(2)                 You can tell which columns have changed by comparing the CurrentVersion of the object with the OriginalVersion.  Here is how you can get the Current and Original FirstName of an Employee:

                    Employee aEmployee = mEmployees[0];

                    String currentFirstName = (String)aEmployee["FirstName", DataRowVersion.Current];

                    String originalFirstName = (String)aEmployee["FirstName", DataRowVersion.Original];

 




Print Page | Close Window