XPO Upcasting & Downcasting

In XPO, when working with persistent objects, a filter allows you to upcast and downcast data.

Consider the following example:

Public Class Contact
    Inherits BaseObject

    Public Sub New(ByVal session As Session)
        MyBase.New(session)
    End Sub

    Private _mFirstName As String
    Private _mLastName As String
    Private _mMiddleName As String

    Public Property FirstName() As String
        Get
            Return _mFirstName
        End Get
        Set(ByVal value As String)
            If String.Compare(_mFirstName, value, False) = 0 Then
                Return
            End If
            _mFirstName = value
        End Set
    End Property
    Public Property LastName() As String
        Get
            Return _mLastName
        End Get
        Set(ByVal value As String)
            If String.Compare(_mLastName, value, False) = 0 Then
                Return
            End If
            _mLastName = value
        End Set
    End Property
    Public Property MiddleName() As String
        Get
            Return _mMiddleName
        End Get
        Set(ByVal value As String)
            If String.Compare(_mMiddleName, value, False) = 0 Then
                Return
            End If
            _mMiddleName = value
        End Set
    End Property
End Class

Public Class Developer
    Inherits Contact

    Private _mLanguage as String
    Public Property Language As String
        Get
            Return _mLanguage
        End Get
        Set(Byval value As String)
            _mLanguage = value
        End Set
    End Property

End Class

When filtering these objects, you can filter developers based on their contact information, but you can also filter contacts based on their developer information, if they are example

Dim cntFilterForContact As New BinaryOperator("Language", "VB.NET")
Dim cntFilterForDeveloper As New BinaryOperator("Language", "VB.NET")

The filters can be used appropriately against the Contact or the Developer object to retrieve all developers who code in VB.NET. Very efficient stuff :)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>