2016-09-06 100 views
0

我在使用Xamarin/C#移动应用程序中的解析。我正在尝试通过updatedAt字段查询表,以便我可以减少由我的应用程序进行的数据调用的数量。我正在使用本地SQlite数据库中最新的“updatedAt”日期查询我的Parse DB。唯一的问题是Parse返回该表中的所有项目。这里是我的功能: -Parse.com - C#查询“updatedAt”返回不正确的结果

public static async Task getNewLiveTips(Action<bool> callback) 
    { 
     DateTime lastDate = App.Current.modelManager.GetOnlyLocalTip().updatedAt; 

     if (lastDate != null) { 

      var query = new ParseQuery<ParseTip>(); 
      query.WhereGreaterThanOrEqualTo("updatedAt", lastDate); 
      IEnumerable<ParseTip> parseTips = await query.FindAsync(); 

      foreach (var tip in parseTips) 
      { 
       Log.Debug(TAG, "Adding new updated live tip item"); 
       App.Current.modelManager.SaveLocalTip(ModelUtils.parseToLocalTip((ParseTip)tip)); 
      } 
     } 

     callback(true); 
    } 

我不做日期的任何操作任何地方,所以从我的本地SQLite数据库的日期如下: -

06/09/2016 12:50:02 

返回的日期是: -

06/09/2016 15:14:23 
17/08/2016 21:12:31 

正如您所看到的,其中一个日期更近,其中一个日期更早。任何人都能发现我的问题吗

感谢

+0

2016年6月9日15时14分23秒 - 是最近的 17/08/2016 21:12:31 - 不太近 查询应该使用“GreaterThan”查询的任一端。 我也收到06/09/2016 12:50:02商品。 –

回答

0

没有设法弄清楚为什么这个功能没有工作,但我设法得到相同的结果做: -

private static async Task getAllLiveTips() 
    { 
     var query = new ParseQuery<ParseTip>().OrderByDescending("updatedAt").Limit(5); 
     IEnumerable<ParseTip> parseTips = await query.FindAsync(); 

     if (parseTips != null) 
     { 

      foreach (var liveTip in parseTips) 
      { 
       Log.Debug(TAG, "Adding live tip item"); 
       App.Current.modelManager.SaveLocalTip(ModelUtils.parseToLocalTip(liveTip)); 
      } 
     } 
    } 
相关问题