Browse files

Using SCOPE_IDENTITY instead of @@identity

  • Loading branch information...
1 parent 61bb804 commit c015abce2472a1681670dcf2c75e71c24a96f8dc @zvolkov committed Jan 24, 2013
Showing with 2 additions and 3 deletions.
  1. +2 −3 Massive.cs
View
5 Massive.cs
@@ -502,9 +502,8 @@ private dynamic BuildPagedResult(string sql = "", string primaryKeyField = "", s
if (BeforeSave(ex)) {
using (dynamic conn = OpenConnection()) {
var cmd = CreateInsertCommand(ex);
+ cmd.CommandText = cmd.CommandText + ";SELECT SCOPE_IDENTITY() as newID";
cmd.Connection = conn;
- cmd.ExecuteNonQuery();
- cmd.CommandText = "SELECT @@IDENTITY as newID";
ex.ID = cmd.ExecuteScalar();
Inserted(ex);
}
@@ -670,4 +669,4 @@ private dynamic BuildPagedResult(string sql = "", string primaryKeyField = "", s
return true;
}
}
-}
+}

0 comments on commit c015abc

Please sign in to comment.