Hi,
i have the following issue.
I have an entity with a n:m relation to another entity, while the linking object is also a real entity with datafields (To be specific, a Reception is m:n linked to a Perceel via a ReceptionPerceel, and a ReceptionPerceel has eg. a Zaaidatum field) . The linking object is shown in a datagrid,and i provide the user with a "delete" button to remove such an object from the collection. Stupid me, i didn't realize backthen that a collection is only a memory representation, and a removal from the collection doesnt actually delete the object from the DB. But it does update the databound grid correctly, the object is not in it anymore.
After some adding/removing the user can save the main entity, and the following buttonhandler is called:
private void btnOpslaan_Click(object sender, System.EventArgs e)
{
PersistData();
m_currentEntity.Refetch();
SetBindings();
this.Refresh();
}
Everything looked ok in the grid after the save action, so i assumed it was all done correctly, after all, i do a refetch, re-set my bindings, and even do a refresh to make sure.
I noticed a bit later on in the database that the m:n relations weren't deleted at all, which i understand now, i solved it, but why didn't the Refetch() show me that ?? (they should re-appear in the grid after the save)
I changed my code then to :
private void btnOpslaan_Click(object sender, System.EventArgs e)
{
PersistData();
m_currentEntity = new ReceptionEntity(m_currentEntity.RecId);//instead of .Refetch()
SetBindings();
this.Refresh();
}
and then indeed the grid shows me that the linkobjects aren't deleted at all.
Now my question : what's the difference between using entity.refetch() and really refetching it yourself - using entity = new Entity(exisiting_id) ?