I've got a table called ItemAttributes that开发者_如何学C is going to have many records for any given parent item record. The user interface allows the user to add/remove ItemAttributes in batch mode and click save one time.
So in the case of update I need to do one of two things.
- Delete all prior ItemAttributes and add all resulting items the user has selected.
- Somehow merge what is new, and what should be deleted and what should be left alone.
I would prefer to do the merge option so that I can mitigate deletes as this causes bad fragmentation over time. What i'm looking for is an elegant solution to this problem using LINQ operators. Thanks in advance.
Use the LINQ set operations http://msdn.microsoft.com/en-us/library/bb546153.aspx
精彩评论