How to change relations in typed list at runtime?

Posts   
 
    
Rene
User
Posts: 54
Joined: 20-Jun-2006
# Posted on: 20-Jun-2006 17:15:42   

Hi,

I have created a typed list with some weak relations (left joins). In some cases I would like to make them strong. The problem is that I cannot access these relations.

MyTypedList typedList = new MyTypedList(); IRelationPredicateBucket filter = (IRelationPredicateBucket)typedList.GetRelationInfo();

filter.Relations doesn't have an "Items" property.

Even when I would be able to access the relation-objects, the "IsWeak"-property is readonly.

So, I thought maybe I can remove the relations and add them again with JoinHint.Inner. But also, in order to remove the relation, I would need to find it in the collection.

I'm using the latest runtime-libraries. I hope someone can suggest a solution.

Thanks! René

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39928
Joined: 17-Aug-2003
# Posted on: 20-Jun-2006 17:48:48   

You can foreach over the Relations property (which is a RelationCollection) if you cast it to the RelationCollection type first. There's an indexer defined as well. Be sure not to remove during the foreach. Though if you want to change the joinhint of a relation, simply search it using foreach, or for and the count property and change the HintForJoins property of the EntityRelation object.

Frans Bouma | Lead developer LLBLGen Pro
Rene
User
Posts: 54
Joined: 20-Jun-2006
# Posted on: 20-Jun-2006 23:46:05   

Ok! That works. I didn't cast to "RelationCollection". I was still addressing it as "IRelationCollection". And, by mistake, I declared the relation as "IEntityRelation" instead of "EntityRelation".

Thanks for the quick reply (once again). Real good support!

René