AussieALF Blog

Oct
20
2011

ObjectLayer… Where is more info?

With 11.2 just around the corner, I figured I would post an update on where I am at.

Currently I stopped my R&D on the ObjectLayer until the 11.2 release, with this release the class and interfaces have had more work done to them (as DX has been working on this implementation for their own systems and also based on feedback from customers).

I believe this is one of the reasons we don’t see alot of documentation on the subject as such, as writing documentation on a evolving set of classes/interfaces would just make alot of work for the tech writers.

As I don’t have alot of R&D time, I wanted to wait until 11.2 which IMHO will be getting closer to a finalised structure (or at least a more extendable structure).

As soon as I can sink my teeth into 11.2 (including any betas that will inevitably be released in the coming month or two) I will be posting my findings and will concentrate on some example projects.

So till then have a Happy Halloween.

 
Oct
20
2011

Simple Result Helper Class

This isn’t XPO related, but just something that I have been using more and more of recently.

Narrowing and Widening overrides can be very handy, in my case I have created a simple helper class called xResult.

Basically this allows me to return type of xResult and allow passing this xResult whereever MyType is required.

When I use it is where I ask a Helper function to obtain some information for me. So in my example I have a function GetCriteria in a base class that returns a xResult.

Now when I call GetCriteria, if there is some interaction which I need to pass back to “cancel” the operation I can return a xResult which has Succeeded as False. Previously the only option I had was to throw an exception and catch it, this of course isn’t a good practice, the other idea could be to return null, however in this case returning null is a perfectly valid result.

I figured I would post it here incase it helped others or if others had any other suggestions regarding this approach.

Public Class xResult(Of T)

    Public Shared Narrowing Operator CType(value As T) As xResult(Of T)
        Return New xResult(Of T)(value)
    End Operator

    Public Shared Widening Operator CType(value As xResult(Of T)) As T
        Return value.Value
    End Operator

    Private fValue As T
    Public ReadOnly Property Value As T
        Get
            Return fValue
        End Get
    End Property

    Public Sub New(Value As T)
        fValue = Value
        fSucceeded = True
    End Sub

    Private fSucceeded As Boolean
    Public ReadOnly Property Succeeded As Boolean
        Get
            Return fSucceeded
        End Get
    End Property

    Public Sub New()
        fValue = Nothing
        fSucceeded = False
    End Sub

    Public Sub New(Message As String)
        fValue = Nothing
        fMessage = Message
        fSucceeded = False
    End Sub

    Public Sub New(Message As String, ex As Exception)
        fValue = Nothing
        fException = ex
        fSucceeded = False
        fMessage = Message
    End Sub

    Private fMessage As String
    Public ReadOnly Property Message As String
        Get
            Return fMessage
        End Get
    End Property

    Private fException As Exception
    Public ReadOnly Property Exception As Exception
        Get
            Return fException
        End Get
    End Property

End Class
 
Aug
01
2011

State of ObjectLayer

OK, well as you probably are aware I have been researching the ObjectLayer for my commercial application which is currently using the serialization of IDataStoreover WCF.

The aim is to blog about how to achieve certain things using the ObjectLayer, however at this stage, I don’t have anything to report other than I found a brick wall that I am working on how to get over Smile with tongue out

 
Jul
29
2011

DevExpress Support Center – My Tags?

OK this one isn’t XPO related however, if you haven’t come across this feature (like myself) then you might be quite happy to learn a bit about it. The Support Center does support favorites, originally there was a favorites system which I had used a little, but when the new one came out I didn’t notice anything to bookmark/favorite an article.

Today I just accidentally found it. So lets look at it.

 
Jul
29
2011

TIP for XPO ThreadSafeDataLayer

When dealing with services or websites where many operations can be requested asynchronously from different threads, you must ensure that you use the ThreadSafeDataLayer.

The DX help document http://documentation.devexpress.com/#XPO/clsDevExpressXpoThreadSafeDataLayertopic does have a little Note which reads:

Prior to performing any operations with persistent objects in a data store using thread-safe data access layers, call the Session.CreateObjectTypeRecords method to obtain complete metadata information on the persistent objects.

Now the problem is, some XPO novices may run into issues, as per “XPO Best Practices” the Default Session should be null and therefore, this will mean that they will create a new Session using their newly created ThreadSafeDataLayer. The issue is here is that the ThreadSafeDataLayer requires all SchemaUpdates/ObjectType records to already be in place (due to the asynchronous ways the ThreadSafeDataLayer cannot safely ensure that if it did a UpdateSchema/CreateObjectTypeRecords that there isn’t already another thread requesting this)

So, what does this note from DX mean?

 

More Articles...

Latest Comments

My Twitter

Follow me on twitter