New Posts New Posts RSS Feed: Relations with more than one entity in between?
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Relations with more than one entity in between?

 Post Reply Post Reply
Author
HFloyd View Drop Down
Groupie
Groupie


Joined: 27-Jul-2007
Location: United States
Posts: 44
Post Options Post Options   Quote HFloyd Quote  Post ReplyReply Direct Link To This Post Topic: Relations with more than one entity in between?
    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
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down