I am working on a WP8 questions application, the application send the data to the DB but will skip the exist data. I have a class called "DBHelper.cs" and it contains
public static void InsertQuestion(Question oQuestion)
{
using (var context = new QuestionContext(ConnectionString))
{
if(context.DatabaseExists())
{
Question oQuestionWord = (from ostd in context.Questions where ostd.Word == oQuestion.Word select ostd).Single();
if (oQuestionWord.Word == null)
{
context.Questions.InsertOnSubmit(oQuestion);
context.SubmitChanges();
}
}
}
}
And this code in the mainpage.xaml.cs
protected override void OnNavigatedTo(NavigationEventArgs e)
{
Question oQuestion = new Question();
oQuestion.Word = "One";
DBHelper.InsertQuestion(oQuestion);``
oQuestion = new Question();
oQuestion.Word = "Two";
DBHelper.InsertQuestion(oQuestion);
oQuestion = new Question();
oQuestion.Word = "One";
DBHelper.InsertQuestion(oQuestion);
base.OnNavigatedTo(e);
}
There is no errors when Building the solution, but it crashes when launching the app.