Otis wrote:
Set the EntityCollection's property EntityFactoryToUse to the factory class with your extended code
(or pass it to the entitycollection's constructor)
Thanks for the reply. I am only fetching one entity from the database:
The CountyEntity has been extended with a Count property:
public partial class CountyEntity {
public Nullable<int> DealerCount {
get {
object value = this.Fields[this.Fields.Count - 1].CurrentValue;
if (value != null) {
return Convert.ToInt32(value);
} else {
return null;
}
}
}
}
and the EntityFactory has been extended to add the new count field:
public class ExtendedCountyEntityFactory : CountyEntityFactory {
public override IEntityFields2 CreateFields() {
IEntityFields2 toReturn = base.CreateFields();
toReturn.Expand(1);
IEntityField2 scalarField = new EntityField2("DealerCount",
new ScalarQueryExpression(CountyFields.CountyId.SetAggregateFunction(
AggregateFunction.Count),
(SellerFields.CountyId == CountyFields.CountyId)));
toReturn.DefineField(scalarField, toReturn.Count - 1);
return toReturn;
}
}
Where in the following code can I set the EntityFactory to use?
DataAccessAdapter adapter = new DataAccessAdapter();
CountyEntity county = new CountyEntity(2);
adapter.FetchEntity(county);