When I try using a SqlServerIdentitySelector, it gives an error "InvalidCastException". To correct this, I had to modify the retrieveIdentity method as follows.
public int retrieveIdentity(IDbConnection connection)
{
int id = -1;
using (IDbCommand cmd = connection.CreateCommand())
{
cmd.CommandText = IdentitySelectStatement();
String str = cmd.ExecuteScalar().ToString();
if (str != null)
{
Int32.TryParse(str, out id);
}
}
return id;
}