A one-layer recursive relation predicate

Posts   
 
    
Dennis
User
Posts: 1
Joined: 11-Dec-2007
# Posted on: 11-Dec-2007 14:20:01   

Hi!

I got a nasty problem with a relation predicate:

We got a composite on one of our tables, let's call it X, which has a foreign key to it's parent, so we can have sets of X. We don't have composites of infinite depth, only one layer down, so we cannot have sets of sets of X. Redundantly we have attribute IsSet set in X, if the tuple is a set.

X has serial numbers, kept in a separate table.

We now want to find all sets (no problem) that match a certain serial number, so we do something like this:

' example 1: searching sets by set attributes

Dim ser As String = "G000:234:456:912:903" Dim bucket As New RelationPredicateBucket bucket.PredicateExpression.AddWithAnd(SerialFields.Number Mod ser) bucket.PredicateExpression.AddWithAnd(XFields.IsSet = True) bucket.Relations.Add(XEntity.Relations.SerialEntityUsingSerialId)

However, that is not the problem I am trying to solve! I also need to find sets, if any child in the set matches the serial no. This is easy in SQL given a recursive left join (as long as only one layer down is needed), but how to do this in LLBL? I know about SetObjectAlias, but this doesn't seem to usable for Relations themselves.

' example 2: searching sets by set attributes and by set child attributes

Dim ser As String = "G000:234:456:912:903" Dim bucket As New RelationPredicateBucket bucket.PredicateExpression.AddWithAnd(SerialFields.Number Mod ser) bucket.PredicateExpression.AddWithAnd(XFields.IsSet = True)

bucket.Relations.Add(XEntity.Relations.SerialEntityUsingSerialId, "ParentSerial", JoinHint.Left)

bucket.Relations.Add(XEntity.Relations.XEntityUsingParent, "Parent", "Child", JoinHint.Left)

' HELP! What to add here refering to "Child" rather than "Parent" which it must refer to ? bucket.Relations.Add( ??? Something a la "Child" Using Parent ???, "ChildSerial")

bucket.PredicateExpression(SerialFields.Number.SetObjectAlias("ChildSerial") Mod ser)

I hope the problem is clear, and what I am trying to do (trying to fetch).

Does anybody have any suggestions? I suspect the answer is rather trivial, but I haven't been able to find anything in the documentation about this, although there is a bit about SetObjectAlias, but nothing for Relations...

Best Regards, Dennis Decker Jensen, Mjolner Informatics

goose avatar
goose
User
Posts: 392
Joined: 06-Aug-2007
# Posted on: 11-Dec-2007 20:30:53   

see this thread: http://llblgen.com/TinyForum/Messages.aspx?ThreadID=11057

if you still have problems, please post the sql query you want to produce and i'll help you out with it.