Skip to content

Instantly share code, notes, and snippets.

@hagbarddenstore
Forked from pmrozik/gist:98afa8e0b59910049806
Last active August 29, 2015 14:13
Show Gist options
  • Save hagbarddenstore/a3e94bd6a4a44ddf2648 to your computer and use it in GitHub Desktop.
Save hagbarddenstore/a3e94bd6a4a44ddf2648 to your computer and use it in GitHub Desktop.
public static void insertWords(List<string> words)
{
var context = new OperationDataContext();
var existingWords = context.GetTable<english_dictionary>().Where(word => words.Contains(word)).ToList();
var wordsToInsert = words.Except(existingWords).ToList();
foreach (var word in wordsToInsert)
{
var dictionary = new english_dictionary { word = word.Trim() };
context.english_dictionaries.InsertOnSubmit(dictionary);
}
context.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