Beispiel #1
0
 public static void Insert(MySqlConnection connection, EthBlock model)
 {
     connection.Execute("INSERT INTO EthBlock VALUES(@blockNo, @blockHash, @timestamp, @blockchainID)", new
     {
         blockNo      = model.BlockNumber,
         blockHash    = model.BlockHash,
         timestamp    = model.Timestamp,
         blockchainID = model.BlockchainID
     });
 }
Beispiel #2
0
 public static void Update(MySqlConnection connection, EthBlock model)
 {
     connection.Execute(
         "UPDATE EthBlock SET BlockNumber = @blockNo, BlockHash = @blockHash, Timestamp = @timestamp, BlockchainID = @blockchainID" +
         " WHERE BlockNumber = @blockNo AND BlockchainID = @blockchainID", new
     {
         blockNo      = model.BlockNumber,
         blockHash    = model.BlockHash,
         timestamp    = model.Timestamp,
         blockchainID = model.BlockchainID
     });
 }
Beispiel #3
0
        public static void InsertOrUpdate(MySqlConnection connection, EthBlock model)
        {
            var count = connection.QueryFirstOrDefault <Int32>("SELECT COUNT(*) FROM EthBlock WHERE BlockNumber = @blockNo AND BlockchainID = @blockchainID", new
            {
                blockNo      = model.BlockNumber,
                blockchainID = model.BlockchainID
            });

            if (count == 0)
            {
                Insert(connection, model);
            }
            else
            {
                Update(connection, model);
            }
        }