Hello Frans.
I'm revisiting a problem that I've mentioned before. Perhaps you can help.
Using Adapter and October 6th Beta of 1.0.2005.1. Using VS.Net 2005.
In my application, a pre-generated collection entity is bound to a grid.
This code generated the data graph:
public EntityCollection GetCatalogueCategories()
{
IPrefetchPath2 prefetchPath = new PrefetchPath2((int)EntityType.CatalogueCategoryEntity);
prefetchPath.Add(CatalogueCategoryEntity.PrefetchPathCatalogueCategoryDetail);
EntityCollection lst = new EntityCollection(new CatalogueCategoryEntityFactory());
ISortExpression sorter = new SortExpression(SortClauseFactory.Create(CatalogueCategoryFieldIndex.Description, SortOperator.Ascending));
DataAccessAdapter adapter = new DataAccessAdapter();
adapter.FetchEntityCollection(lst, null, 0, sorter, prefetchPath);
return lst;
}
The data is bound to the grid:
bindingSourceTabs.DataSource = Categories.Items ;
Changing the row on the grid triggers this grid event:
private void grdViewTabs_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
{
bindingSourceDetail.DataSource = ((CatalogueCategoryEntity)CurrentEntity()).CatalogueCategoryDetail.Items;
}
Interestingly, this method alone calls the InitClassEmpty event (for CatalogueCategoryDetailEntity !??!!) which is a follows:
For CatalogueCategoryDetailEntity....
protected virtual void InitClassEmpty(IValidator validator, IEntityFields2 fields)
{
InitClassMembers();
base.Fields = fields;
base.IsNew=true;
base.Validator = validator;
// __LLBLGENPRO_USER_CODE_REGION_START InitClassEmpty
if (fields.State == EntityState.New)
{
CategoryType = 1;
}
// __LLBLGENPRO_USER_CODE_REGION_END
}
As I step through the code, I see that fields.State == EntityState.New.
It's confusing to me that the child InitClassEmpty method is called at all. All we're doing is attaching one of the parent's collections (CatalogueCategoryDetails) to a datasource. It's even more confusing that the state is found to be EntityState.New. Hence, CategoryType is always set to new, even though the child entities are pre-fetched.
This is proving difficult to de-bug. Any ideas on how I can track down the problem?
Thank.
Jeff