public override void SetRangeInHash(string key, IEnumerable <KeyValuePair <string, string> > keyValuePairs)
        {
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            if (keyValuePairs == null)
            {
                throw new ArgumentNullException(nameof(keyValuePairs));
            }

            _storage.UseTransaction(connection =>
            {
                foreach (var keyValuePair in keyValuePairs)
                {
                    var oracleDynamicParameters = new OracleDynamicParameters();
                    oracleDynamicParameters.AddDynamicParams(new { KEY = key, FIELD = keyValuePair.Key });
                    oracleDynamicParameters.Add("VALUE", keyValuePair.Value, OracleMappingType.NClob, ParameterDirection.Input);

                    connection.Execute(
                        @"
 MERGE INTO HF_HASH H
      USING (SELECT 1 FROM DUAL) SRC
         ON (H.KEY = :KEY AND H.FIELD = :FIELD)
 WHEN MATCHED THEN
     UPDATE SET VALUE = :VALUE
 WHEN NOT MATCHED THEN
     INSERT (ID, KEY, FIELD, VALUE)
     VALUES (HF_SEQUENCE.NEXTVAL, :KEY, :FIELD, :VALUE)
",
                        oracleDynamicParameters);
                }
            });
        }
Beispiel #2
0
 public override void Commit()
 {
     _storage.UseTransaction(connection =>
     {
         foreach (var command in _commandQueue)
         {
             command(connection);
         }
     });
 }