Programming update screnerio

Associate
Joined
6 Jan 2006
Posts
1,023
Location
Midlands
Hi

I have an user object. This user can belong in many departments. I have stored the user departments using an Array inside the user object.

When it comes to updating the user object back to the database. How will able to tell which new departments the user now belong to and same with which department the user no longer belong to?

The only method i can think of is removing all departments the user belong to and the then add the departments from the array list every time i update the user. However this do not sound very efficient to me. Is there a better way?

Thanks.
 
Presumably the department object in the array will have an ID, and if the ID is empty then it hasn't been read from the database (and therefore must be new)?

As for updates, you could have a HasChanges boolean that gets set to true when any of the properties of the object are changed.
 
Back
Top Bottom