I need receive data just from Users table and sorted by one of the columns. let’s call it “SortField”.
i use the following method for it :
public static BackendlessAPI.Data.BackendlessCollection<BackendlessAPI.BackendlessUser> GetUser(string whereClause, string property)
{
PersistenceService persistenceService = new PersistenceService();
BackendlessDataQuery dataQuery = new BackendlessDataQuery(whereClause);
dataQuery.Offset = 1;
dataQuery.QueryOptions = new QueryOptions()
{
SortBy = new List<string> { property }
// internal weborb error appear
};
// dataQuery.Properties = new List<String> { property };
BackendlessCollection<BackendlessUser> freeUsers = persistenceService.Find<BackendlessUser>(dataQuery);
return freeUsers;
}
when i remove SortBy option all works perfect. But when i execute query with SortBy = new List<string> { property } line, error inside of webord.dll appear “An unhandled exception of type ‘System.NullReferenceException’ occurred in weborb.dll” (see file attached.)
I specially applied part of code from your PersistenceServiceTest.cs
[TestMethod()] public void findWithSortByConditionTest() { string entityName = “Person”; //for (int i = 0; i < 15; i++) //{ // Dictionary<string, object> dict = new Dictionary<string, object>(); // dict.Add(“Name”, “test” + i); // dict.Add(“Age”, 20 + i); // persistenceService.Save(entityName, dict); //} try { BackendlessDataQuery query = new BackendlessDataQuery(); query.QueryOptions = new QueryOptions { SortBy = new List<string> { “Name” } }; var ps = persistenceService.Find<Person>(query); Assert.IsNotNull(ps); } catch (BackendlessException ex) { Assert.AreEqual(“adafa”, ex.Code); } }
and still receiving this error.