Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Ok more of a conceptual question here:

Say I have an existing record of type Meeting. When I go to edit the meeting I have a listbox with all current meeting participants, and one with all employees. I then add a few employees from the master list and remove a couple from the meeting list. What is then the best approach to update my MeetingParticipant database with the new roster? The add records are no problem, but when I go to update, my callback doesn't know which items I have removed. Here are the solutions I've considered/implemented so far, but I'm hoping someone has a better answer :).

  1. Immediately resolve the record deletion when the employee has been removed from the list. (this is what I usually implement, but I'd rather find a way where I can simply update the entire collection upon form submission)
  2. Remove all MeetingParticipant records for the meeting and repopulate with the new list. (could possibly cause some referential integrity problems for employees who's status did not change)
  3. Iterate through each of the MeetingParticipant records, searching the new list to see if it's still on the list or not. (seems like a lot of overkill)

If it matters, we're working w/in the .Net framework using MVC & LINQ.

share|improve this question

migrated from stackoverflow.com Aug 9 '12 at 22:12

This question came from our site for professional and enthusiast programmers.

1 Answer 1

Just add kind of state property to your records.

Your record can potentially have at least 3 states

  1. Added
  2. Deleted
  3. Changed

When your server/base/whatever.. recives the raw data-table from the UI, it just iterates over the collection and based on state of every record in that data-table executes appropriate operation.

Hope this helps.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.