Phill Wiggins Phill Wiggins - 3 months ago 10
Android Question

Parse.com - C# query "updatedAt" returns incorrect results

I am using Parse in a mobile application I am working on Xamarin/C#. I am trying to query a table by the updatedAt field so that I can reduce the amount of data calls being made by my application. I am querying my Parse DB with the most recent "updatedAt" date in my local SQlite DB. The only issue is Parse is returning all items within that table. Here is my function:-

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);
}


I don't do any manipulation of dates anywhere so the date from my local SQLite DB looks like this:-

06/09/2016 12:50:02


The dates returned are:-

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


As you can see, one of the dates is more recent and one of the dates is older. Can anyone spot my issue?

Thanks

Answer

Didn't manage to figure out why this function didn't work but I managed to get the same results doing:-

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));
            }
        }
    }