When using the DevExpress.XPO.XPView to retrieve data, you could encounter an exception when trying to skip items with the “SkipReturnedRecords” property. (This property comes in handy when paging data, for example.)
The exception is an System.InvalidOperationException, and it message says: “Can not skip records without ORDER BY clause.”. The message is pretty clear, because you cannot skip records without first specifying in which way the list should be returned. This is explained pretty well for the XPQuery object.
However, for the XPView this works a bit differenty. Because setting the “Sorting” property of the XPView will not help here. The Sorting property is used to order the records after they have been fetched (so also after the SkipReturnedRecords has been evaluated).
The solution is to set the “Sorting” property on one of ViewProperty objects that have been added to the “Properties” of the XPView. This property will ensure that the query includes an ORDER BY clause when trying to skip records.
XPView xpView = new XPView();
xpView.Properties.Add(new ViewProperty("ID", SortDirection.Ascending, "ID", false, true));
xpView.SkipReturnedRecords = 5;
By the way, the company that I work at is looking for new ASP.NET developers. Especially DevExpress developers! So check the site Concepts2Go.com or call me at: + 31 (0)30 677 32 01.