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();
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();
Change InsertOnSubmit
to Add
.
Change SubmitChanges
to SaveChanges
.
There is no bool
argument needed for Attach
.