Collection Classes

Posts   
 
    
hommels
User
Posts: 23
Joined: 01-Jul-2005
# Posted on: 05-Jul-2005 14:40:18   

How would you fix this code to use Adpater model

PersonCollection pc = new PersonCollection();

IPredicateExpression select = new PredicateExpression(); select.Add( PredicateFactory.CompareValue( PersonFieldIndex.NetworkUsername, ComparisonOperator.Equal, Environment.UserName ) ); try { pc.GetMulti( select );

} catch ( Exception ex ) { Console.WriteLine( ex ); // TODO: Trap if DB Connection string has not been set (integrated or standard not specified in DB ) // TODO: Trap if no catalog was selected

} return pc[0];

JimFoye avatar
JimFoye
User
Posts: 656
Joined: 22-Jun-2004
# Posted on: 05-Jul-2005 15:27:17   

hommels wrote:

How would you fix this code to use Adpater model

PersonCollection pc = new PersonCollection();

IPredicateExpression select = new PredicateExpression(); select.Add( PredicateFactory.CompareValue( PersonFieldIndex.NetworkUsername, ComparisonOperator.Equal, Environment.UserName ) ); try { pc.GetMulti( select );

} catch ( Exception ex ) { Console.WriteLine( ex ); // TODO: Trap if DB Connection string has not been set (integrated or standard not specified in DB ) // TODO: Trap if no catalog was selected

} return pc[0];

There may be some variations, but this should work (have only typed this in, so watch for typos):

   EntityCollection coll = new EntityCollection(new PersonEntityFactory());
            IRelationPredicateBucket bucket = new RelationPredicateBucket();
            bucket.PredicateExpression.Add(PredicateFactory.CompareValue(PersonFieldIndex.NetworkUsername, ComparisonOperator.Equal, Environment.UserName));
            adapter.FetchEntityCollection(coll, bucket, 0, null);

Adapter doesn't have typed collections, so you always work with EntityCollection but of course your code should normally know which kind of entities it's being passed.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 05-Jul-2005 20:37:11   

Thanks Jim simple_smile

Frans Bouma | Lead developer LLBLGen Pro