Commit b991bf3f authored by David Chell's avatar David Chell

Fix bug in updating keys in object after insert

parent d93b0991
...@@ -486,14 +486,9 @@ public int Insert(IDbConnection connection, IDbTransaction transaction, int? com ...@@ -486,14 +486,9 @@ public int Insert(IDbConnection connection, IDbTransaction transaction, int? com
//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", transaction: transaction, commandTimeout: commandTimeout); var r = connection.Query("select @@IDENTITY id", transaction: transaction, commandTimeout: commandTimeout);
int id = 0; int id = (int)r.First().id;
foreach (var p in keyProperties) if (keyProperties.Any())
{ keyProperties.First().SetValue(entityToInsert, id, null);
var value = ((IDictionary<string, object>)r.First())[p.Name.ToLower()];
p.SetValue(entityToInsert, value, null);
if (id == 0)
id = Convert.ToInt32(value);
}
return id; return id;
} }
} }
......
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