Proper way to add RelationCollection to IRelationPredicateBucket

Posts   
 
    
arschr
User
Posts: 894
Joined: 14-Dec-2003
# Posted on: 31-Dec-2005 21:25:26   

I have a RelationCollection r that I want to use in a IRelationPredicateBucket b.

I cant':

b.relations = r;

(It's a read only property) I can't:


for( int i = 0; i<r.count;i++)
{
  b.r.add(r[i]);
}

(It loses the aliases and join hints. Is there a way to get them out so I can use and overload of add?)

Edit: I've found the SetAliases method on IEntityRelation but there doesn't seem to be corresponding GetStartAlias() and GetEndAlias().

I think I can use IsWeak to determine the JoinHint to use. So if I had the getStartAlias and GetEndAlias, I could use a Add override to do what I want.

and


b.relations.addrange(r);
or
b.relations.addrange((ICollection)r);

gives me errors (Something about ICollection<T>).

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 02-Jan-2006 11:00:15   

use b.relations.AddRange((RelationCollection)r);

You have to cast to RelationCollection, as IRelationCollection doesn't implement ICollection and the AddRange() accepts an ICollection.

Frans Bouma | Lead developer LLBLGen Pro
arschr
User
Posts: 894
Joined: 14-Dec-2003
# Posted on: 02-Jan-2006 13:44:38   

Thanks. That worked.