Sep
15
2009

XPO Simplified Criteria Syntax

User Rating: / 0
PoorBest 

For some reason had some issues setting this up but in the end it all worked great.

Basically download this plugin and place it in your %USERPROFILE%\My Documents\DevExpress\IDE Tools\Community\PlugIns

http://community.devexpress.com/blogs/xpo/archive/2009/10/02/ann-dxcore-xpo-plugin-1-2-0-4.aspx

Then go into your DevExpress options (CTRL+ALT+SHIFT+O) and go to IDE > Shortcuts, I then added a new Shortcut and in my case set it to CTRL+1 then set the Use to Editor > Code> In XPO Persistent Class (this will ensure that if you press CTRL+1 outside of a XPO class it won’t run)

And now whenn you press your Shortcut within an XPO Class you should get a FieldsClass created like:

#Region "XPO nested fields class - don't edit manually"
        Public Shadows Class FieldsClass
            Inherits BMS.Base.Data.BaseObject.FieldsClass
            Public Sub New()
                MyBase.New()
            End Sub
            Public Sub New(ByVal propertyName As String)
                MyBase.New(propertyName)
            End Sub
            Public ReadOnly Property Title() As OperandProperty
                Get
                    Return New OperandProperty(GetNestedName("Title"))
                End Get
            End Property
            Public ReadOnly Property ID() As OperandProperty
                Get
                    Return New OperandProperty(GetNestedName("ID"))
                End Get
            End Property
        End Class
        Private Shared _fields As FieldsClass
        Public Shared Shadows ReadOnly Property Fields() As FieldsClass
            Get
                If ReferenceEquals(_fields, Nothing) Then
                    _fields = New FieldsClass()
                End If
                Return _fields
            End Get
        End Property
#End Region

And should be able to create Criteria like

        Using Clients As New XPCollection(Of Client)(session, _
                             New BinaryOperator(Client.Fields.AccountManager, _
                                 New OperandValue(BMS.Base.CurrentUser(session)), _
                                 BinaryOperatorType.Equal), _
                             Nothing)
            For Each Client As Client In Clients
                Debug.Print(Client.TradingName & " is managed by " & BMS.Base.CurrentUser(session).Fullname)
            Next
        End Using

Or another way I use it is for type safe binding

    Private Sub Bind(ByVal control As Control, ByVal datamember As OperandProperty)
        control.DataBindings.Add(New Binding("EditValue", Client, datamember.PropertyName))
    End Sub
 
    Private Sub frmClient_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Bind(TradingNameLabel, Client.Fields.TradingName)
    End Sub

Add comment

Although I believe your free to say what you want, please don't abuse either myself or other peoples, be constructive.


Security code
Refresh

Should AussieALF stay bald?




Results

Latest Comments

My Twitter

Follow me on twitter