IdeaBlade.EntityModel.Server Assembly > IdeaBlade.EntityModel.Server Namespace : EntityServerSaveInterceptor Class |
'Declaration
<DefaultExportAttribute(IsDefault=True, ContractName="", ContractType=IdeaBlade.EntityModel.Server.EntityServerSaveInterceptor)> Public Class EntityServerSaveInterceptor
'Usage
Dim instance As EntityServerSaveInterceptor
[DefaultExport(IsDefault=true, ContractName="", ContractType=IdeaBlade.EntityModel.Server.EntityServerSaveInterceptor)] public class EntityServerSaveInterceptor
At all times during the lifecycle you have access to the Principal for the user issuing the save.
A new instance of your EntityServerSaveInterceptor is created for each save request.
// Server-side implementation of EntityServerSaveInterceptor public class EntityServerSaveManager : EntityServerSaveInterceptor { // Always require explicit authorization attributes on entities. protected override bool DefaultAuthorization { get { return false; } } // Log errors to any listening loggers. protected override void OnError(Exception e, PersistenceFailure failureType) { TraceFns.WriteLine("Save error: " + e.Message); } // Customized save logic. protected override bool ExecuteSave() { // Pre-save logic. var em = EntityManager; var addedEmps = em.FindEntities(EntityState.Added).OfType<Employee>(); // Mark any added emps with "Added at". addedEmps.ForEach(emp => emp.Notes = "Added at" + DateTime.Now); // Execute the save. var ok = base.ExecuteSave(); // After save logic. if (ok) { // Log any type of saved to an Employee. var emps = EntityManager.FindEntities(EntityState.Added | EntityState.Deleted | EntityState.Modified).OfType<Employee>(); TraceFns.WriteLine("Emps saved: " + emps.Count()); } return ok; } }
System.Object
IdeaBlade.EntityModel.Server.EntityServerSaveInterceptor
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2