0

我有以下代码:

Me.ASPxMenu1.DataSource = New HierarchicalMenuItemCollection(New XPCollection(Of IMenuItem)(DirectCast(WebApplication.Instance.ObjectSpaceProvider.CreateObjectSpace(), XPObjectSpace).session,
                                               CType(New NullOperator("ParentItem"), CriteriaOperator),
                                               New SortProperty("Order", DB.SortingDirection.Ascending)))

它在 DirectCast 中失败,在 DevExpress 11.2 中它是

Ctype(WebApplication.Instance.ObjectSpaceProvider.CreateObjectSpace(), ObjectSpace).Session

有人知道如何在 DevExpress 12.2 中做到这一点吗?感谢您的任何帮助

4

1 回答 1

0

回答自己的问题:

正确的方法是

Dim xpObjectSpaceProvider As New XPObjectSpaceProvider(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString, Nothing)
Dim ObjectSpace As IObjectSpace = xpObjectSpaceProvider.CreateObjectSpace()

Me.ASPxMenu1.DataSource = New HierarchicalMenuItemCollection(New XPCollection(Of IMenuItem)(CType(ObjectSpace, XPObjectSpace).Session,
                                               CType(New NullOperator("ParentItem"), CriteriaOperator),
                                               New SortProperty("Order", DB.SortingDirection.Ascending)))
于 2013-04-22T14:25:39.993 回答