private static void Write(Person person) { // For writing new person and updating exisitng person var newPerson = new Klib.Person(); var existingPersonCount = db.Persons .Select(thisPerson => thisPerson.UID == person.UID) .Count(); newPerson = Build(person); if (existingPersonCount == 0) newPerson.UID = person.UID; db.Persons.InsertOnSubmit(newPerson); db.SubmitChanges(); }
private static Klib.Person Build(Person person) { var builtPerson = new Klib.Person(); builtPerson.UID = person.UID; builtPerson.FirstName = person.FirstName; builtPerson.LastName = person.LastName; builtPerson.Location = person.Location; return builtPerson; }