Commit d35b72e3 authored by Sam Saffron's avatar Sam Saffron

the transaction is not really needed there ... it helps with nothing.

parent b60c0a53
...@@ -146,8 +146,7 @@ private static string GetTableName(Type type) ...@@ -146,8 +146,7 @@ private static string GetTableName(Type type)
/// <returns>Identity of inserted entity</returns> /// <returns>Identity of inserted entity</returns>
public static long Insert<T>(this IDbConnection connection, T entityToInsert, IDbTransaction transaction = null, int? commandTimeout = null) where T : class public static long Insert<T>(this IDbConnection connection, T entityToInsert, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
{ {
using (var tx = connection.BeginTransaction())
{
var type = typeof(T); var type = typeof(T);
var name = GetTableName(type); var name = GetTableName(type);
...@@ -180,10 +179,9 @@ private static string GetTableName(Type type) ...@@ -180,10 +179,9 @@ private static string GetTableName(Type type)
sb.Append(") "); sb.Append(") ");
connection.Execute(sb.ToString(), entityToInsert, transaction: transaction, commandTimeout: commandTimeout); connection.Execute(sb.ToString(), entityToInsert, transaction: transaction, commandTimeout: commandTimeout);
//NOTE: would prefer to use IDENT_CURRENT('tablename') or IDENT_SCOPE but these are not available on SQLCE //NOTE: would prefer to use IDENT_CURRENT('tablename') or IDENT_SCOPE but these are not available on SQLCE
var r = connection.Query("select @@IDENTITY id"); var r = connection.Query("select @@IDENTITY id", transaction: transaction, commandTimeout: commandTimeout);
tx.Commit();
return (int)r.First().id; return (int)r.First().id;
}
} }
/// <summary> /// <summary>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment