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.