views:

112

answers:

0

Given these Entities auto generated by EF...(pseudo)

class CreditCard
{
    int ID {get;set;}
    string Number {get;set;}
}
class Person
{
    EntityCollection<CreditCard> CreditCards {get; set;}
}

What is the best way to merge a disconnected List into the CreditCards property of Person.

A List will be constructed on a WebForm based on UserInput. The list will contain new CreditCards (adds), changes to existing CreditCards (updates), and will NOT contain CreditCards that the user has removed.

Next (the challenge I need help with) is to take that disconnected List and Merge it with the CreditCards property of the Person instance,

That merging process will (A) Add new instances to the list, (B) Update existing instances AND (C) Delete instances not present in the disconnected list.

Is there a defacto way that EF is designed to handle this, or is it a manual process ? If manual, what is the best way to achieve this in a generic way that can be reused across entities?