You say you have to use SelfServicing, however if this is a new project, you're highly recommended to use Adapter. RelationPredicatebucket is an Adapter construct.
I recon, the relationships are: Structure m:1 Element and Structure m:1 Rights ? As Element is a parent of Rights, it'll be joined twice due to the inheritance
var qf = new QueryFactory();
var q = qf.Structure
.From(QueryTarget.InnerJoin(qf.Element).On(StructureFields.PermissionID.Equal(ElementFields.ID)))
.InnerJoin(qf.Rights).On(StructureFields.ParentID.Equal(RightsFields.ID)))
.Where(ElementFields.ObjectID.Equal("some-guid"));
using(var adapter = new DataAccessAdapter())
{
var results = adapter.FetchQuery(q);
// do something with results
}
This is a queryspec variant of the query you posted (see https://www.llblgen.com/Documentation/5.8/LLBLGen%20Pro%20RTF/QuerySpec.htm). The join with Rights doesn't make sense, see below.
You can also write the query as a linq query, however it's recommended to use either queryspec or linq for fetch queries.
You mention prefetch paths but the example you give, rights, is already in the query, so it's unclear why you want to fetch related entities of that type.
As you're trying to fetch entities, and I think you fetch structure entities here?, you don't need to join entities which aren't going to be fetched nor involved in a predicate. Here, you filter on a field in Element, but you also join Rights, but there's no need to do that.
If you want to fetch structure entities, and their related right entities, based on a filter on element, then the query becomes:
var qf = new QueryFactory();
var q = qf.Structure
.From(QueryTarget.InnerJoin(qf.Element).On(StructureFields.PermissionID.Equal(ElementFields.ID)))
.Where(ElementFields.ObjectID.Equal("some-guid"))
.WithPath(StructureEntity.PrefetchPathRights);
using(var adapter = new DataAccessAdapter())
{
var results = adapter.FetchQuery(q);
// do something with results
}
Here I've specified 1 join, namely the one which is used in the filter, and the rights are fetched as a prefetch path node. This query can also be done in linq if you want to. (or the low level API, but it's recommended to use linq or queryspec). See: https://www.llblgen.com/Documentation/5.8/LLBLGen%20Pro%20RTF/Using%20the%20generated%20code/QuerySpec/gencode_queryspec_prefetchpaths.htm