public int Insert <T>(T item) { using (var connection = GetConnection()) { using (var command = connection.CreateCommand()) { command.MapFrom(InsertStatement.For(item)); connection.Open(); var result = command.ExecuteNonQuery(); connection.Close(); return(result); } } }
public static int InsertInto <T>(this IDbConnection connection, string table, T item) { using (new ConnectionStatePreserver(connection)) { using (var command = connection.CreateCommand()) { var statement = InsertStatement.For(item, table); command.MapFrom(statement); connection.OpenIfClosed(); var result = command.ExecuteNonQuery(); return(result); } } }
public int InsertInto <T>(string table, T item) { using (var connection = GetConnection()) { using (var command = connection.CreateCommand()) { var statement = InsertStatement.For(item, table); command.MapFrom(statement); connection.Open(); var result = command.ExecuteNonQuery(); connection.Close(); return(result); } } }