Hello, I am having a problem with entity classes I need your help with.
Version 2.6 Final.
I am using the following class definition:
public partial class frmCampus : Form
{
public frmCampus(CampusEntity campus)
{
InitializeComponent();
m_campus = campus;
}
// Data
private CampusEntity m_campus;
}
Now this form allows the user to edit the campus entity being passed in (using data binding). However when the user tabs out of the name field I do some duplicate record checks and show some possible matches. If the user selects one of the possible matches I need to re-init the m_campus member with the selected row in the database.
If I do:
m_campus = new CampusEntity(newPK);
Sure enough m_campus now represents the new entity and all the binding on the form is correct.
The problem is however that m_campus now points at a new instance of CampusEntity and the original passed in CampusEntity (in the constructor of the form) is still pointing at the original instance (created outside of the form).
So outside of the form we don't have a reference to the newly selected record.
So, simple I though. Just use the FetchUsingPK record on the existing entity? No, this does not appear to work. I get some of the values back, but all of the relations are left in a strange state. The FK ID's are correct, but the members that point to the relating entities themselves are invalid.
Is there a way to completely re-init an existing entity instance, using the PK, that will also re-init any FK members?
Sorry for the long winded message.
Thanks in advance for your help.
David