constructor OracleTableDependency only event Insert

Apr 14, 2016 at 10:32 AM
HI, is possible use constructor with DmlTriggerType enum of type Insert ?
I would like to manage only message insert, but i have exception , because the param UpdateOfModel is required with DmlTriggerType, and accept only enum "Update".
May 11, 2016 at 7:47 PM
Hi romofa

I started work on it

Bye
Jun 7, 2016 at 12:29 PM
Hi

I have checked my integration test. I have a specific test for that:
        [TestCategory("Oracle")]
        [TestMethod]
        public void OnlyInsert()
        {
            OracleTableDependency<TriggerTypeTestOracleModel> tableDependency = null;
            string naming = null;

            try
            {
                tableDependency = new OracleTableDependency<TriggerTypeTestOracleModel>(
                    ConnectionString,
                    TableName,
                    null,
                    (IList<string>)null,
                    DmlTriggerType.Insert,
                    true);
                tableDependency.OnChanged += TableDependency_Changed;
                tableDependency.Start();
                naming = tableDependency.DataBaseObjectsNamingConvention;

                Thread.Sleep(1000);

                var t = new Task(ModifyTableContent);
                t.Start();
                t.Wait(5000);
            }
            finally
            {
                tableDependency?.Dispose();
            }

            Assert.AreEqual(_counter, 1);

            Assert.AreEqual(CheckValues[ChangeType.Insert.ToString()].Item2.Name, "Pizza Mergherita");
            Assert.AreEqual(CheckValues[ChangeType.Insert.ToString()].Item2.Surname, "Pizza Mergherita");

            Assert.IsTrue(OracleHelper.AreAllDbObjectDisposed(ConnectionString, naming));
        }

        private static void ModifyTableContent()
        {
            CheckValues.Add(ChangeType.Insert.ToString(), new Tuple<TriggerTypeTestOracleModel, TriggerTypeTestOracleModel>(new TriggerTypeTestOracleModel { Id = 23, Name = "Pizza Mergherita", Surname = "Pizza Mergherita" }, new TriggerTypeTestOracleModel()));
            CheckValues.Add(ChangeType.Update.ToString(), new Tuple<TriggerTypeTestOracleModel, TriggerTypeTestOracleModel>(new TriggerTypeTestOracleModel { Id = 23, Name = "Pizza Funghi", Surname = "Pizza Mergherita" }, new TriggerTypeTestOracleModel()));
            CheckValues.Add(ChangeType.Delete.ToString(), new Tuple<TriggerTypeTestOracleModel, TriggerTypeTestOracleModel>(new TriggerTypeTestOracleModel { Id = 23, Name = "Pizza Funghi", Surname = "Pizza Funghi" }, new TriggerTypeTestOracleModel()));

            using (var connection = new OracleConnection(ConnectionString))
            {
                connection.Open();
                using (var command = connection.CreateCommand())
                {
                    command.CommandText = $"BEGIN INSERT INTO {TableName} (ID, NAME, SURNAME) VALUES ({CheckValues[ChangeType.Insert.ToString()].Item1.Id}, '{CheckValues[ChangeType.Insert.ToString()].Item1.Name}', '{CheckValues[ChangeType.Insert.ToString()].Item1.Surname}'); END;";
                    command.ExecuteNonQuery();
                    Thread.Sleep(1000);

                    command.CommandText = $"BEGIN UPDATE {TableName} SET NAME = '{CheckValues[ChangeType.Update.ToString()].Item1.Name}'; END;";
                    command.ExecuteNonQuery();
                    Thread.Sleep(1000);

                    command.CommandText = $"BEGIN DELETE FROM {TableName}; END;";
                    command.ExecuteNonQuery();
                    Thread.Sleep(1000);
                }
            }
        }
and all works fine.

what Is the exception you get ?