Check if an insert or update was successful in Entity Framework

前端 未结 3 1099
眼角桃花
眼角桃花 2021-01-18 05:25

In ADO.NET, ExecuteNonQuery() \"For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command\" (http://msdn.microsoft.com/en-us/

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-18 06:06

    Maybe this is not direct answer to the question, but may help. By default all commands are encapsulated in one DbTransaction when SaveChanges method is called (Julia Lerman, Programming Entity Framework). So, or all commands will be successfully executed, or neither. That's one way to know if insert, or update or delete was successful.

提交回复
热议问题