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