Example #1
0
        internal static List <FullWord> GetFullWordListByListID(int id)
        {
            List <VocabularyList_Word> vlWords = VocabularyList_Word.Fetch("WHERE VocabularyListID = @0 ORDER BY Rank", id);

            int[]           wordIDs = vlWords.Select(t => t.WordID).ToArray();
            List <FullWord> vlFW    = SuomenkieliRepository.GetFullWordList(wordIDs);

            return(vlFW);
        }
Example #2
0
        internal static void OrderVocabularyList(string list, int[] order)
        {
            List <VocabularyList_Word> vlWords = VocabularyList_Word.Fetch("WHERE VocabularyListID = @0", list);

            Sql updateSQL = new Sql(@"UPDATE [VocabularyList_Word] 
                SET Rank = CASE WordID");

            for (int i = 0; i < order.Length; i++)
            {
                int wordID = order[i];
                VocabularyList_Word vlWord = vlWords.First(w => w.WordID == wordID);
                vlWord.Rank = i;
                updateSQL.Append("WHEN @0 THEN @1", wordID, i);
                //vlWord.Update(); // TODO: A more efficient version.
            }
            updateSQL.Append("END");
            updateSQL.Append("WHERE VocabularyListID=@0 AND WordID IN (@1)", list, order);

            db.Execute(updateSQL);
        }