Exemplo n.º 1
0
 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);
         }
     }
 }
Exemplo n.º 3
0
 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);
         }
     }
 }