public void InitializeDatabase()
 {
     //load settingsfile
     using (var db = SQLiteConnectionHelper.GetConnection(_db))
     {
         //this will create the table if it doesn exist, upgrade if it has changed, or nothing if it is the same
         db.CreateTable <Day>();
         db.CreateTable <HighScoreList>();
         db.CreateTable <Score>();
     }
 }
        public void ClearHighScoreList(string highScoreList)
        {
            lock (locker)
            {
                using (var connection = SQLiteConnectionHelper.GetConnection(_db))
                {
                    connection.Execute(
                        @"delete from Scores 
						where HighScoreListId IN ( 
							select Id from HighScoreList
							where Name = ? )"                            , highScoreList);
                }
            }
        }
        public IEnumerable <Tuple <string, uint> > GetHighScoreList(string highScoreList, int num)
        {
            lock (locker)
            {
                using (var connection = SQLiteConnectionHelper.GetConnection(_db))
                {
                    //get the scores from
                    var scores = connection.Query <Score>(
                        @"select * from Scores as s
						inner join HighScoreList as hsl on s.HighScoreListId = hsl.Id
						where hsl.Name = ?
						order by s.Points desc
						limit ?"                        , highScoreList, num);

                    //convert to tuples
                    return(scores.Select(x => new Tuple <string, uint>(x.Initials, x.Points)));
                }
            }
        }
        public void AddHighScore(string highScoreList, uint points, string initials, DateTime?date = null)
        {
            lock (locker)
            {
                using (var connection = SQLiteConnectionHelper.GetConnection(_db))
                {
                    var highScoreListId = SaveHighScoreList(connection, highScoreList);
                    var dayId           = SaveDay(connection, date);

                    //Add the new high score
                    connection.Insert(new Score
                    {
                        Points          = points,
                        Initials        = initials,
                        DayId           = dayId,
                        HighScoreListId = highScoreListId
                    });
                }
            }
        }