Print Page | Close Window

Example of TriggerTargetNavigator

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=354
Printed Date: 10-Jun-2026 at 6:01pm


Topic: Example of TriggerTargetNavigator
Posted By: Customer
Subject: Example of TriggerTargetNavigator
Date Posted: 03-Aug-2007 at 11:53am
Do you have an example of how the TriggerTargetNavigator is used? I'm trying to implement cross object verification but can't seem to get it to work.



Replies:
Posted By: eileenv
Date Posted: 03-Aug-2007 at 12:05pm

The TriggerTargetNavigator represents a delegate for navigating from the trigger object to the object being verified. The navigator can either be a path (PropertyDescriptor) or a custom method capable of bridging the two object types.

Here’s an example taken from the sample app accompanying the Verification Tutorial videos on the website, where the navigator is a path:

///<summary>Get the OrderDateAfterHired Verifier.</summary>
private static Verifier GetOrderDateAfterHiredVerifier() {
  string description = "OrderDate must be after the sales rep's HireDate.";
  DelegateVerifier<Order> v =
    new DelegateVerifier<Order>(description, OrderDateAfterHiredCondition);
  v.ExecutionModes = VerifierExecutionModes.InstanceAndOnPostsetTriggers;
  v.AddTrigger(EntityPropertyDescriptors.Order.OrderDate);
  v.AddTrigger(new TriggerLink(
    EntityPropertyDescriptors.Employee.HireDate, // Triggered by Employee.HireDate
    EntityPropertyDescriptors.Employee.Orders, // Path from trigger (Employee) to Order
    true)); // True = that path returns multiple orders
  return v;
} 

Here’s an example where the navigator is a custom method:

private static Verifier GetOrderDateDiscontinuedProductVerifier() {

  string description = "No orders allowed for discontinued products after 1/1/1998";
  DelegateVerifier<Order> v =
    new DelegateVerifier<Order>(description, GetOrderDateDiscontinuedProductCondition);
  v.ExecutionModes = VerifierExecutionModes.All;
  v.AddTrigger(EntityPropertyDescriptors.Order.OrderDate);
  v.AddTrigger(new TriggerLink(
    EntityPropertyDescriptors.Product.Discontinued, // Triggered by Product.Discontinued
    GetOrdersAssociatedWithProduct, // Method bridging orders and products
    true); // True = that method returns multiple orders
  return v;
}
private static EntityList<Order> GetOrdersAssociatedWithProduct(Object pProduct) {
  Product aProduct = (Product)pProduct;
  OrderDetail[] details = aProduct.GetChildren<OrderDetail>(
    EntityRelations.Product_OrderDetail,
    QueryStrategy.Normal);
  EntityList<Order> orders = aProduct.PersistenceManager.GetParents<Order>(
    details, EntityRelations.Order_OrderDetail, QueryStrategy.Normal);
  return orders;
}



Print Page | Close Window