Debugging LINQ on Windows Phone -
i new windows phone programming, , trying simple application run. however, have difficulties debugging.
on creation of database want insert default data:
using (dodatacontext db = new dodatacontext(dbconnectionstring)) { if (db.databaseexists() == false) { // create local database. db.createdatabase(); datetime datefields = new datetime(2013, 1, 1, 0, 0, 0); // prepopulate categories. db.languages.insertonsubmit(new dolanguage { code = "en", name = "english", lastupdate = datefields }); db.languages.insertonsubmit(new dolanguage { code = "fr", name = "french", lastupdate = datefields }); db.languages.insertonsubmit(new dolanguage { code = "es", name = "spanish", lastupdate = datefields }); db.menuitems.insertonsubmit(new domenuitem { id = 3, title = "test 3", lastupdate = datefields, level = 1, action = "article/1", commonid = 1, section = "", icon = "", published = true, _languageid = 1 }); // save categories database. db.submitchanges(); } }
however, on 'db.menuitems.insertonsubmit' application crashes , following console output (db.languages.insertonsubmit works fine):
the thread '' (0x18630716) has exited code 0 (0x0). thread '' (0x183809e2) has exited code 0 (0x0). thread '' (0x191d0b02) has exited code 0 (0x0).
there no info, , have no idea goes wrong. suggestions how debug problem?
_languageid = 1
, it's not there in database yet when you're adding menu.
you can many ways, example save in 2 shots,
db.languages.insertonsubmit(new dolanguage { code = "en", name = "english", lastupdate = datefields }); db.languages.insertonsubmit(new dolanguage { code = "fr", name = "french", lastupdate = datefields }); db.languages.insertonsubmit(new dolanguage { code = "es", name = "spanish", lastupdate = datefields });
and call save changes
, should work, should not have specify id of menu item.
Comments
Post a Comment