public Kanji GetKanjiFromDatabase(int kanjiId)
        {
            using (KanjiDataContext context = new KanjiDataContext(connectionString)) {

                var data = from k in context.Kanji where k.Id == kanjiId select k;

                if (data.Count() == 0)
                    return null;

                return data.First();
            }
        }
        public void LoadFromDatabase(List<string> kanjiList)
        {
            kanjiDictionary = new Dictionary<string, Kanji>();

            using (KanjiDataContext context = new KanjiDataContext(connectionString)) {

                var data = from k in context.Kanji where kanjiList.Contains(k.Literal) select k;

                kanjiList.ForEach(k => kanjiDictionary.Add(k, data.First(d => d.Literal == k)));

                if (App.AppSettings.IsRandomReviewList)
                    GenerateRandomSequence();
                else
                    GenerateSequence();
            }
          
        }
        public void LoadFromDatabase(JLPT jlptLevels)
        {
            kanjiDictionary = new Dictionary<string, Kanji>();

            using (KanjiDataContext context = new KanjiDataContext(connectionString)) {

                var data = from k in context.Kanji where k.JLPTLevel == (jlptLevels & k.JLPTLevel) select k;

                data.ToList().ForEach(k => kanjiDictionary.Add(k.Literal, k));

                if (App.AppSettings.IsRandomFlashcards)
                    GenerateRandomSequence();
                else
                    GenerateSequence();
            }
                
        }
        public void CopyData()
        {
            using (KanjiDataContext context = new KanjiDataContext(connectionString)) {

                if (context.DatabaseExists())
                    context.DeleteDatabase();
                context.CreateDatabase();

                using (var odb = ODBFactory.Open(baseFilePath)) {
                    var data = odb.GetObjects<KanjiData>();

                    foreach (var kanji in data) {
                        context.Kanji.InsertOnSubmit(new Kanji() { Id = kanji.Id, JLPTLevel = kanji.JLPTLevel, KunYomi = kanji.KunYomi, Literal = kanji.Literal, Meaning = kanji.Meaning, OnYomi = kanji.OnYomi, StrokeCount = kanji.StrokeCount });
                    }

                    context.SubmitChanges();

                }
            }


        }
        public Kanji GetKanjiFromDatabase(string literal)
        {
            using (KanjiDataContext context = new KanjiDataContext(connectionString)) {

                var data = from k in context.Kanji where k.Literal == literal select k;

                if (data.Count() == 0)
                    return null;

                return data.First();
            }
        }