Print Page | Close Window

EntityServerSaveInterceptor

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3095
Printed Date: 21-Oct-2025 at 10:29pm


Topic: EntityServerSaveInterceptor
Posted By: Vincent
Subject: EntityServerSaveInterceptor
Date Posted: 15-Nov-2011 at 2:12am
Hi Everybody
 
Can anyone give me a sample code on how to get both old and new property values of an entity that has been modified by implementing EntityServerSaveInterceptor on the server side?
 
 
Best Regards,
Vincent



Replies:
Posted By: Walid
Date Posted: 15-Nov-2011 at 8:54am
Hello Vincent,
 
Here is a litle example :
 
    class MyEntityServerSaveManager : EntityServerSaveInterceptor  
    {
        protected override bool ExecuteSave()
        {
 
            foreach (var entity in EntityManager.FindEntities(EntityState.Modified).OfType<MyEntity>())
            {
                var oldValue = (string)EntityAspect.Wrap(entity).GetValue("MyStringProperty", EntityVersion.Original);
                var newValue = entity.MyStringProperty;
                if (oldValue != newValue)
                {
                //...
                }

            }
            
            return base.ExecuteSave();
        }
 
    }


-------------


Posted By: Vincent
Date Posted: 23-Nov-2011 at 7:45pm
Hi Walid
 
Thank you for the help. I have implemented it and it has worked.
 
Best Regards,
Vincent



Print Page | Close Window