I assumed that the cause was in some other code, but I have run the following test. I prepared a nice word document for you with screenshots to assist, but it wasn't possible to upload documents, so I hope that this is enough. I mixed up a couple of tablesearlier, so I hope that you don't get too confused. The table that I am having trouble with is StockSum.
1
At first, i located relevant data using Query Analyzer. I had one record in the Stock table and two related records in the StockSum table.
2
The following code is used to fill a list with all StockEntities.
EntityCollection entities = new EntityCollection(new StockEntityFactory());
adapter.FetchEntityCollection(entities, null);
return entities;
3
The user doubleclicks on a row in a grid and the StockEntity item is passed on to the code below. All Subcollections are loadad.
try
{
DataAccessAdapter adapter = GetAdapter();
IPrefetchPath2 prefetchPath = new PrefetchPath2((int)EntityType.StockEntity);
prefetchPath.Add(StockEntity.PrefetchPathStockExtraValue);
prefetchPath.Add(StockEntity.PrefetchPathStockTrans);
prefetchPath.Add(StockEntity.PrefetchPathStockSum);
//
// Fetch data
//
adapter.FetchEntity(entity, prefetchPath);
System.Diagnostics.Debug.WriteLine("LoadStock for StockId" + entity.Id.ToString() + " returned " + entity.StockSum.Count.ToString() + " StockSumEntities");
return true;
}
catch(Exception ex)
{
System.Diagnostics.Debug.Assert(false, ex.ToString());
}
return false;
4
I have a breakpoint at "return true" and added 4 watches. The data looks just like in the databasen
5
Next thing I do is that I change the values in the database. Name of the stock is changed, as well as the field Qty in the underlying StockSum table.
6
Once again the user doubleclicks a row and the code under section 3 is executed. Another stop at my breakpoint. I now see that the Name of the StockEntity has been updated. The underlying StockSumEntity has however not been updated. If i run the code under section 2, however (i.e. update the list) the updates are reflected