How do I upsert a record in ADO.NET EF 4.1?

后端 未结 5 1979
走了就别回头了
走了就别回头了 2021-01-01 23:22

I\'m trying to accomplish something really simple and I can\'t find how to do it using Entity Framework 4.1.

I want a controller method that accepts an object and

5条回答
  •  误落风尘
    2021-01-01 23:58

    To perform an UPSERT operation, You might want to consider creating an SP that performs a MERGE.

    http://www.databasejournal.com/features/mssql/article.php/3739131/UPSERT-Functionality-in-SQL-Server-2008.htm

    Whatever way you choose the operation must be atomic or you'll have a race condition. Your SP will probably need a HOLDLOCK to void this ...

    http://weblogs.sqlteam.com/dang/archive/2009/01/31/UPSERT-Race-Condition-With-MERGE.aspx

提交回复
热议问题