views:

52

answers:

1

hi I have the code below could you help me please to rewrite from LINq to SQL to Linq to Entity. thank you

if(account.AccountID > 0)
{
   dc.Accounts.Attach(account, true);
}
else
{
   dc.Accounts.InsertOnSubmit(account);
}

dc.SubmitChanges();
A: 

Change InsertOnSubmit to Add.

Change SubmitChanges to SaveChanges.

There is no bool argument needed for Attach.

Craig Stuntz