devartmysql-dependent-subquery

How to get the operation type in devart MysqlDependency


I know I can get the table name that recently changed using Devart MysqlDependency by using the following code.

void dependency_OnChange(object sender, Devart.Data.MySql.MySqlTableChangeEventArgs e) {
  string tableName=e.TableName;
}

But I want to know, Is there any way to get the operation type like: insert, update or delete?
Iam using c# winforms.


Solution

  • Unfortunately MySqlTableChangeEventArgs does not contain information about the type of event (INSERT, UPDATE, DELETE). https://www.devart.com/dotconnect/mysql/docs/Devart.Data.MySql~Devart.Data.MySql.MySqlTableChangeEventArgs_members.html

    In order to determine the kind of transaction you can do the following:

    1. Create triggers for each kind of transaction (INSERT, UPDATE, DELETE)
    2. The triggers should write the necessary information (timestamp, record id, table name, type of operation, etc…) into a special tracking table
    3. Use MySqlDependency for monitoring this tracking table only.
    4. In the MySqlDependency.OnChange event handler get the necessary information from the tracking table.