I have an entity that is fetched with a prefetch, using this construct: MyCustomEntity.Fetch() which returns an instance of MyCustomEntity filled with all data.
Then I put the entity in session.
Then I edit the entity stored in session and items in its member properties.
Then I call adapter.SaveEntity(entityToSave); entity to save is the entity that was in session. This marks the entity as out of synch and makes it unusable.
So now I have to refetch the entity. If I use this method, adapter.SaveEntity(entityToSave, true) the select statement that is run at the end of the save does not appear to be populating all entities specified in the original prefetch.
I thought that maybe I needed to add my entity to context before calling SaveEntity. This did not work as only a partial graph is returned and I am getting a null reference exception pointing to one of the member properties of my entity that was saved.
This is what my code looked like after adding the context:
using (DataAccessAdapter adapter = new DataAccessAdapter(ConnectionString))
{
Context currentContext = new Context();
currentContext.Add(entityToSave);
adapter.SaveEntity(entityToSave , true);
}
So my question is, should the SaveEntity(entityToSave , true) do the select using the preexisting prefetch and return all of the objects again?