我有以下代码:
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中如何做到这一点? 感谢您提供任何帮助
答案 0 :(得分: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)))