Print Page | Close Window

View-backed Business Objects

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=1833
Printed Date: 23-Apr-2025 at 1:14pm


Topic: View-backed Business Objects
Posted By: evanian
Subject: View-backed Business Objects
Date Posted: 20-May-2010 at 9:59am
I have had reason to create a business entity class backed by a view that cannot be updated, and  I would like to allow entities of this class to be editable in my application.  However, I want to prevent these view-backed entities being saved to the database, since to attempt this will cause a database error.

Is there any way to mark an entity class or a set of objects as being not-for-saving so that the Persistence Manager knows not to attempt to save them to the database?  Thanks in advance for any help anyone might have!



Replies:
Posted By: IdeaBlade
Date Posted: 21-May-2010 at 5:06pm

The PersistenceManager has a (client-side) Saving event that you can handle to inspect (and change) the collection of Entities being submitted for a save.  The handler gets an EntitySavingEventArgs parameter that has an Entities property which is an IList<Entity> and contains all the Entities being submitted. Simply remove the entities you don't want submitted from that list.




Print Page | Close Window