I am using LLBLGen 2.5 with the SelfServicing model.
I have the following entities and relations:
RequestEntity ------- LoginUserEntity
|
ClientUserEntity ---------- ClientEntity
The LoginUserEntity hierarchy is held in a single table. ClientUserEntity is an abstract SubType of LoginUserEntity that has a number of concrete SubTypes for various user types. The relation between ClientEntity and ClientUserEntity is based on a PK Field of ClientEntity that is held in the ClientUserEntity SubType (not in LoginUserEntity).
I had previously used the following code to in PerformSelect() for a datasource to select a list of RequestEntities related to a particular ClientEntity:
ClientUserEntity clientUser = getCurrentClient();
IPredicateExpression filter = new PredicateExpression();
RelationCollection relations = new RelationCollection();
// link to ClientEntity
relations.Add(RequestEntity.Relations.LoginUserEntityUsingUserId);
relations.Add(ClientEntity.Relations.ClientUserEntityUsingClientId);
filter.Add(ClientFields.ClientId == clientUser.ClientId);
e.ContainedCollection.GetMulti(filter, 0, sort, relations, pageNumber, pageSize);
However, I now find that this code gives me a runtime error:
Relation at index 1 doesn't contain an entity already added to the FROM clause. Bad alias?
Commenting out the relation from ClientEntity to ClientUserEntity (and the filter) removes the problem but (obviously) performs the wrong selection.
This code definitely worked with version 2.0 of LLBLGen. I have upgraded to version 2.5 some time ago and just discovered this erorr .. I don't know whether the upgraded version is the problem.
I tried deleting and regenerating all of my LLBLGen generated code but this did not make a difference.
I looked everywhere for an explicit method of including the ClientUserEntity in the query and tried using GetSubTypeRelation() but when I did this I just got a different error.
What am I missing?
Thanks.