I have the following code for updating Account table with LINQ to SQL. AccountNumber is the primary key column. The only value which need to be updated is AccountType; howev
This should do:
int number = 4;
var acc1 = new accountRepository.Accounts.Where(a => a.Number == number).FirstOrDefault();
if (acc1 == null)
{
// Not found by ID, create new
acc1 = new RepositoryLayer.Account();
acc1.Number = number;
accountRepository.Accounts.AddObject(acc1);
}
acc1.AccountType = "Verify";
accountRepository.SubmitChanges();