This project is read-only.

OnChanged Event

Occurs when a notification is received for any change on the table's records associated with this OracleTableDependency object.

Syntax

public event ChangedEventHandler<T> OnChanged

Example

static void Main()
{
    var mapper = new ModelToTableMapper<Product>();
    mapper.AddMapping(c => c.Description, "Long Description");

    using (var tableDependency = new OracleTableDependency<Product>(
        ConnectionString,
        TableName,
        modelToTableMapper: mapper))
    {
        tableDependency.OnChanged += tableDependency_Changed;
        tableDependency.OnError += tableDependency_OnError;

        tableDependency.Start();
        Console.WriteLine("Waiting for receiving notifications...");
        Console.WriteLine("Press a key to exit");
        Console.ReadKey();
    }
}

static void tableDependency_OnError(object sender, ErrorEventArgs e)
{
    Console.WriteLine(e.Error.Message);
}

static void tableDependency_Changed(object sender, RecordChangedEventArgs<Product> e)
{
    if (e.ChangeType != ChangeType.None)
    {
        var changedEntity = e.Entity;
        Console.WriteLine("DML operation: " + e.ChangeType);
        Console.WriteLine("ID: " + changedEntity.Id);
        Console.WriteLine("Name: " + changedEntity.Name);
        Console.WriteLine("Long Description: " + changedEntity.Description);
    }
}

Last edited Sep 10, 2015 at 11:42 AM by delbianco, version 2