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);
                }
            });
        }
예제 #2
0
        public override void SetRangeInHash(string key, IEnumerable <KeyValuePair <string, string> > keyValuePairs)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }
            if (keyValuePairs == null)
            {
                throw new ArgumentNullException("keyValuePairs");
            }

            _storage.UseTransaction(connection =>
            {
                foreach (var keyValuePair in keyValuePairs)
                {
                    connection.Execute(@"
begin
	update HANGFIRE_Hash set VALUE = :value where KEY = :key and FIELD = :field;
	
	if (sql%rowcount = 0) then
		insert into HANGFIRE_Hash (KEY, FIELD, VALUE) values (:key, :field, :value);
	end if;
end;
",
                                       new { key = key, field = keyValuePair.Key, value = keyValuePair.Value });
                }
            });
        }
 public override void Commit()
 {
     _storage.UseTransaction(connection =>
     {
         foreach (var command in _commandQueue)
         {
             command(connection);
         }
     });
 }
예제 #4
0
        public override void Commit()
        {
            _storage.UseTransaction(connection =>
            {
                connection.EnlistTransaction(Transaction.Current);

                foreach (var command in _commandQueue)
                {
                    command(connection);
                }
            });
        }