Self-Referencing Entities

Posts   
 
    
digizen
User
Posts: 8
Joined: 10-Nov-2004
# Posted on: 17-Feb-2008 23:06:13   

I find it really problematic that LLBLGen does not allow you to create self-referential relationships in Entities.

Let me give an example:

In a program I am writing, I am keeping a list of messages, so I have created a Message entity in LLBLGen. Messages in the program can have one or more "parent" records, so I created a MessageParent entity, which has two useful fields: MessageChild and MessageParent. The resulting graph is then similar to a file system that allows "hard links" -i.e., a node can have multiple parents.

Now, for some reason, LLBLGen will not let me create a m->n relationship between Messages to get to the parents. Therefore, the code I have write to deal with the situation is extremely obtuse. Instead of being able to say: Message.Parents, my only solution seems to be the following:

Message.MessageParentViaMessageChild.MessageViaMessageParent

Which in my view is terribly confusing. Am I missing something? Can anyone assist?

(I am using VS 2008 / LLBLGen 2.5 on a WinXP box)

Thank you in advance for any suggestions, Greg Sherman

garrett
User
Posts: 33
Joined: 21-Feb-2008
# Posted on: 21-Feb-2008 21:36:02   

Hi, I'm facing something similar, when you try to add m:n the reference yourself (side A as a 1:n and side B as a m:1) it will only let you select a relation from side A

Is it some sort of logic to try and prevent circular references ?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 27-Feb-2008 09:59:56   

It's indeed to stop circular references. Another thing is that m:n relations with self are very inefficient. You can also do a query on the same entity with a filter and get the same result.

Frans Bouma | Lead developer LLBLGen Pro