Concurrency resolution enhancements for ObjectNetworkAttacher

Thread is closed for posting
1 posts, 0 answers
  1. C21635A1-567A-4677-8BE8-62E9D9FEDC25
    C21635A1-567A-4677-8BE8-62E9D9FEDC25 avatar
    193 posts
    Member since:
    May 2005

    Posted 29 Sep 2009 Link to this post

    Requirements

    RadControls version

    Open Access 2009.07.26
    .NET version

    2.0 and higher
    Visual Studio version

    2005 and higher
    programming language

    C#
    browser support not applicable

    PROJECT DESCRIPTION
    The point of this example is to demonstrate the usage of the Telerik.OpenAccess.Helper.ObjectNetworkAttacher in handling concurrency issues when reattaching objects to an ObjectScope.  The ObjectNetworkAttacher is not included with the Telerik OpenAccess ORM assemblies but is deployed as a helper class in its installation folders.
    What needs enhancement is the fact it uses the plain Exception class to raise concurrency problems. The provided project introduces a new ConflictException Class with a specific ConflictExceptionType member in order to be able to handle different types of conflicts.

    The attached solution has 3 projects. The first is the updated ObjectNetworkAttacher with the new classes.  The second one is a sample business model with just one class representing a version controlled object.  The third is a client console application that demonstrates the four types of conflicts that can occur. The four conflicts are:
    • updating an already updated record;
    • updating a deleted record;
    • deleting an already deleted record;
    • inserting an already existing record;
    Have in mind that this application has been created using the full version of SQL Server. For those of you that use SQLEXPRESS you will need to change the app.config file accordingly.

    Gotchas
    There are two gotchas that can occur when running the reverse engineering wizard and dealing with objects that use version control fields.  For some reason the version control field (called versionid in this application) does not get generated in either file and therefore I had to manually add it to the user file.  The second gotcha is that in the *.Telerik.OpenAccess.cs file the VersionField attribute is not generated automatically and it must be manually added. It should look something like this:
    [Telerik.OpenAccess.Persistent(IdentityField = "id", VersionField = "versionid")] 
    The ObjectNetworkAttacher is a great lightweight way to deal with connecting objects that were created or changed outside of an ObjectScope. Now with enhanced exception handling - it's even better!  Enjoy.

    Al
Back to Top

This Code Library is part of the product documentation and subject to the respective product license agreement.