dimanche 29 mars 2015

Handling the result of a SQLite aggregate function on Windows Phone

I'm working on an app (SleepTracker) and I'm trying to put together a statistic feature based on data saved in a SQLite database using different aggregate functions. What I'm trying to achieve is to query the table with an aggregate function that I've wrote already, and store the result in a string that is bound to a textblock on the View. However, I can't figure out how I would go about doing this because it only seems to work if the results are stored in some sort of list like an OC which seems to be overkill for just needing a single result such as a count, or a max value. Is there a way that I could achieve this that I'm completely ignoring?


For example, here's what I'm working with right now;



using (var conn = new SQLiteConnection(App.ConnectionString))
{
var latestTime = @"SELECT time(max(SleepTime))
FROM SleepTrackerModel
WHERE Date > (SELECT DATETIME('now', '-7 day'))";
conn.Query<SleepTrackerModel>(latestTime);
}


Then I have a string "LatestTime" which is bound to a textblock on the View. I was hoping that the result of the query could just be stored as the value of that string and that'd be it, but it doesn't seem to work like that.


Any help would be great, and if I've missed out any important information here, I'll edit asap.


Thanks.


Aucun commentaire:

Enregistrer un commentaire