Print Page | Close Window

Relations with more than one entity in between?

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=943
Printed Date: 28-Mar-2025 at 1:34am


Topic: Relations with more than one entity in between?
Posted By: HFloyd
Subject: Relations with more than one entity in between?
Date Posted: 19-Sep-2008 at 10:24pm
Hi,

I reviewed the video tutorial on Many-to-Many relations, but can't figure out how to apply it to a relationship that has more than a single entity between the two entities.

Here is my case:

I have a Household Entity, which can have many Transactions (like Orders). Each Transaction has many LineItems (like Orderdetail), certain of those LineItems could be for tickets to an event, in which case, related records are added to EventTicketSales (generally including the names of the guests attending the event), so for a LineItem of "Event Tickets Qty = 4", four separate EventTicketSales would be created.

Here is a diagram of the relations:
Household --> Transaction --> LineItem --> EventTicketSale

I was able to follow the tutorial to create a relation property in Transaction for "EventTicketSales", but an unsure how to create a relation property in Household for "EventTicketSales" since  "EntityRelations.Transaction_EventTicketSale" doesn't exist.

Is there some way to accomplish this?

Thank you!

Heather



Replies:
Posted By: GregD
Date Posted: 20-Sep-2008 at 12:14pm
I believe this should work (in the Household class):
 
    public EntityList<EventTicketSale> TicketSales {
      get {
        PersistenceManager pm = this.PersistenceManager;
        EntityList<LineItem> lineItems =
          pm.GetChildren<LineItem>(this.Transactions, EntityRelations.Transaction_LineItem, QueryStrategy.Normal);
        EntityList<TicketSale> ticketSales =
          pm.GetChildren<TicketSale>(lineItems, EntityRelations.LineItem_TicketSale, QueryStrategy.Normal);
        return ticketSales;
      }
    }
Greg Dunn



Print Page | Close Window