DevForce Help Reference
EntityServerSaveInterceptor Class
Members  Example 


Provides server-side interception of save processing.
Object Model
EntityServerSaveInterceptor ClassEntityManager ClassSaveOptions ClassVerifierEngine Class
Syntax
'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 
Remarks
You may intercept and customize save processing at several points during the save lifecycle. The save request is first authorized before any further actions are taken: see DefaultAuthorization, AuthorizeSave and ClientCanSave for information. Next validation can be performed on the entities: see ValidateSave. Finally the save is executed: see ExecuteSave. Save processing can be cancelled at any point in the lifecycle.

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.

Example
// 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;
  }
}
Inheritance Hierarchy

System.Object
   IdeaBlade.EntityModel.Server.EntityServerSaveInterceptor

Requirements

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

See Also

Reference

EntityServerSaveInterceptor Members
IdeaBlade.EntityModel.Server Namespace

Send Feedback