DevForce Help Reference
EntityServerQueryInterceptor Class
Members  Example 


Provides server-side interception of query processing.
Object Model
EntityServerQueryInterceptor ClassEntityManager ClassIEntityQuery InterfaceEntityQueryFilterCollection Class
Syntax
'Declaration
 
<DefaultExportAttribute(IsDefault=True, 
   ContractName="", 
   ContractType=IdeaBlade.EntityModel.Server.EntityServerQueryInterceptor)>
Public Class EntityServerQueryInterceptor 
'Usage
 
Dim instance As EntityServerQueryInterceptor
[DefaultExport(IsDefault=true, 
   ContractName="", 
   ContractType=IdeaBlade.EntityModel.Server.EntityServerQueryInterceptor)]
public class EntityServerQueryInterceptor 
Remarks
You may intercept and customize query processing at several points during the query lifecycle. The query is first authorized before any further actions are taken: see DefaultAuthorization, AuthorizeQuery and ClientCanQuery for information. Next the query can be filtered to modify the query to be executed: see FilterQuery and QueryFilters for more information. Next the query is executed: see ExecuteQuery. Finally the query results can be authorized: see ShouldAuthorizeQueryResult and AuthorizeQueryResult. Query processing can be cancelled at any point in the lifecycle.

At all times during the lifecycle you have access to the Query and the Principal for the user issuing the query.

A new instance of your EntityServerQueryInterceptor is created for each query request.

Example
// Server-side implementation of EntityServerQueryInterceptor
public class EntityServerQueryManager : EntityServerQueryInterceptor {

  // Always require explicit authorization attributes on entities.
  protected override bool DefaultAuthorization {
    get { return false; }
  }

  protected override bool FilterQuery()
    // Add filters - let's restrict everything to UK.
    QueryFilters.AddFilter<Customer>(q => q.Where(c => c.Country == "UK"));
    QueryFilters.AddFilter<Employee>(q => q.Where(e => e.Country == "UK"));
    return true;
	}

  // Log errors to any listening loggers.
  protected override void OnError(Exception e, PersistenceFailure failureType) {
    TraceFns.WriteLine("Query error: " + e.Message);  
  }

}
Inheritance Hierarchy

System.Object
   IdeaBlade.EntityModel.Server.EntityServerQueryInterceptor

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

EntityServerQueryInterceptor Members
IdeaBlade.EntityModel.Server Namespace

Send Feedback