News, examples, tips, ideas and plans.
Thoughts around ORM, .NET and SQL databases.

Thursday, October 11, 2012

DataObjects.Net Extensions update

DataObjects.Net Extensions for DataObjects.Net 4.5.5 and 4.6.0 are available.

Changes

  •     Added missing xmldocs for BulkOperations extension
  •     New Tracking extension (DataObjects.Net Extensions 4.6.0 only)

Tracking extension

Tracking extension provides tracking/auditing functionality on Session/Domain level.

To use it:

1. Add reference to Xtensive.Orm.Tracking assembly

2. Include types from Xtensive.Orm.Tracking assembly into the domain:
<Xtensive.Orm>
  <domains>
    <domain ... >
      <types>
        <add assembly="your assembly"/>
        <add assembly="Xtensive.Orm.Tracking"/>
      </types>
    </domain>
  </domains>
</Xtensive.Orm>

3. To track changes on Session level obtain an instance of ISessionTrackingMonitor through Session.Services.Get<ISessionTrackingMonitor>() method To track changes on Domain level (from all sessions) obtain an instance of IDomainTrackingMonitor through Domain.Services.Get<IDomainTrackingMonitor>() method

4. Subscribe to TrackingCompleted event. After each tracked transaction is committed you receive the TrackingCompletedEventArgs object.

5. TrackingCompletedEventArgs.Changes contains a collection of ITrackingItem objects, each of them represents a set of changes that occured to an Entity within the transaction committed.

Example

1. Subscribe to ISessionTrackingMonitor/IDomainTrackingMonitor TrackingCompleted event
var monitor = Domain.Services.Get<IDomainTrackingMonitor>();
monitor.TrackingCompleted += TrackingCompletedListener;

2. Do some changes to persistent entities
using (var session = Domain.OpenSession()) {
  using (var t = session.OpenTransaction()) {
    var e = new MyEntity(session);
    e.Text = "some text";
    t.Complete();
  }
}

3. Handle TrackingCompleted event call and do whatever you want with tracked changes.
private void TrackingCompleted(object sender, TrackingCompletedEventArgs e)
{
  foreach (var change in e.Changes) {
    Console.WriteLine(change.Key);
    Console.WriteLine(change.State);

    foreach (var value in change.ChangedValues) {
      Console.WriteLine(value.Field.Name);
      Console.WriteLine(value.OriginalValue);

      Console.WriteLine(value.NewValue);
    }
  }
}

Sync extension

Sync extension was planned for 4.6 release. We decided that it is not production ready and postponed it until 4.7.

Download

4 comments:

  1. I have to search sites with relevant information on given topic hire someone to write a paper and provide them to teacher our opinion and the article.

    ReplyDelete
  2. Thanks for sharing your perspective! Learn about residential mailbox builders in Logan on our website

    ReplyDelete
  3. Thank you for sharing this update. Keep it up! positivity clothing

    ReplyDelete
  4. A recent upgrade to Data Objects.Net Extensions includes some new additions that are sure to benefit developers. The enhanced integration capabilities and optimized data handling will make managing complex data structures much easier. For individuals working on Btec assignments, this update could be a game changer, providing improved tools for dealing with complex data tasks. If you are seeking for Btec Assignment Help., check out these new features; they can give you the edge you need to succeed in your studies.

    ReplyDelete