|
|
Introduction
OpenAccess is an enhancer based framework by Vanatec which persists your business objects to a database. But there are still some aspects like tracing, which cries out for an implementation using enhancer based technologies. As OpenAcces is focused on perststence only, we need PostSharp to do the rest, but is it possible to use this two frameworks on the same object? Yes, it is, after some adjustments by Vanatec, I get a running sample.
Details
First you need OpenAccess Express by Vanatec, its a free version, which only runs against free databases like MS SQL Server Express or mySQL. After installation of OpenAcces you will find a new menue in your Visual Studio environment, please read the related documentation. Before you can use the sample, you have to establish a database connection. You can use 'OpenAccess/Enable Project' menue and follow the instructions there. Now, OpenAccess takes care of the persistence aspect of our business object 'SomeBusinessObject'. This class is also decorated with the 'MyFieldAccessAspect' attribute which tells PostSharp to enhance all field operations with code of the class 'MyFieldAccessAspect'. Refere the 'FieldAccessSample' above to get more information.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button1.Click
Dim obj As SomeBusinessObject = New SomeBusinessObject
obj.Text = "Hallo"
With ObjectScopeProvider1.GetNewObjectScope
.Transaction.Begin()
.Add(obj)
.Transaction.Commit()
End With
End SubCreate a new instance of 'SomeBusinessObject' and set the 'Text' property. The field access aspect will report this operation to the immediate window of your IDE. Create a locical connection to the database, start a transaction, add the object and commit the operation. Now you can find the data in the underlying table created and written by OpenAccess.
This sample is in a very early stage and will be enhanced in the futur.
Sign in to add a comment
