1
4

2 回答 2

4

这应该这样做:

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();
于 2012-06-25T09:44:09.640 回答
1
于 2012-06-26T05:50:49.217 回答