Marek
Marek

Reputation: 1

How to convert Linq to SQL to Linq Entity?

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();

Upvotes: 0

Views: 526

Answers (1)

Craig Stuntz
Craig Stuntz

Reputation: 126547

Change InsertOnSubmit to Add.

Change SubmitChanges to SaveChanges.

There is no bool argument needed for Attach.

Upvotes: 2

Related Questions