Last active
August 29, 2015 14:13
-
-
Save pmrozik/98afa8e0b59910049806 to your computer and use it in GitHub Desktop.
insertWords method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Put all the words from the dictionary file in the database | |
public static void insertWords(List<string> wordList) | |
{ | |
OperationDataContext odContext = new OperationDataContext(); | |
int wordID = 0; | |
foreach (string word in wordList) | |
{ | |
english_dictionary dictionary = new english_dictionary(); | |
word.Trim(); | |
// Check whether word is already in dictionary | |
var queryWords = from dword in odContext.GetTable<english_dictionary>() | |
where dword.word == word | |
select dword; | |
if(queryWords.Count() > 0) | |
{} | |
else | |
{ | |
Console.WriteLine("Adding {0}....", word); | |
dictionary.word = word; | |
dictionary.wordID = wordID++; | |
odContext.english_dictionaries.InsertOnSubmit(dictionary); | |
} | |
} | |
odContext.SubmitChanges(); | |
Console.WriteLine("Database insert operations complete."); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment