New Posts New Posts RSS Feed: Tech Tip: Span Queries
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Tech Tip: Span Queries

 Post Reply Post Reply
Author
IdeaBlade View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 30-May-2007
Location: United States
Posts: 353
Post Options Post Options   Quote IdeaBlade Quote  Post ReplyReply Direct Link To This Post Topic: Tech Tip: Span Queries
    Posted: 06-Jun-2007 at 11:37am

Level 200
DevForce Express

April 18, 2006

Sometimes you want more than just the business objects that match your search criteria; you want their related business objects as well. You want a "span" query.

A span query is a regular query with attached requests for related objects. Every query returns a primary object type. In a span query, we add "span" requests for objects that are linked to the primary object type by one (or more) mapped "relations".

In the query shown below, we retrieve all Orders placed within the last 7 days. We also want the Customers who placed these orders, their OrderDetails, and the Products purchased in those OrderDetails. Accordingly we add two spans, one reaching "upward" from Order to Customer and another reaching "downward", first to OrderDetail then and from OrderDetail to Product. 

C#:

RdbQuery query1 = new RdbQuery(typeof(Order),

  Order.OrderDateEntityColumn, EntityQueryOp.GT,

  DateTime.Today - new TimeSpan(7, 0,0, 0));

query1.AddSpan(EntityRelations.Customer_Order);

query1.AddSpan(EntityRelations.Order_OrderDetail,

  EntityRelations.Product_OrderDetail); 

VB.NET:

Dim query1 As RdbQuery = New RdbQuery(GetType(Order), _

  Order.OrderDateEntityColumn, EntityQueryOp.GT, _

  DateTime.Today - new TimeSpan(7, 0, 0, 0))

query1.AddSpan(EntityRelations.Customer_Order)

query1.AddSpan(EntityRelations.Order_OrderDetail, _   EntityRelations.Product_OrderDetail)

 

Span queries provide a very effective method of quickly to collect a graph of business objects either for performance reasons or because the user wants to cache objects before going into disconnected mode.

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down