So I have this LINQ expression that simply tries to retrieve a Entity from the database, but when it runs, the app just closes and no exceptions are thrown. I put a try catch around it to see if I could see the exception, but the debugger simply stops at the LINQ Expression and doesn't get inside the catch or runs anything after that, for example the folderId assignment afterwards; like I said it just closes the program. Any ideas?
Item folder = null;
try
{
folder = entities.Items.Where(i => i.Path + "\\" == folderPath).FirstOrDefault();
}
catch(Exception)
{
Console.WriteLine("What is it??!!");
}
int folderId = folder == null ? 0 : folder.ID;
FolderPath is a valid string. Already checked and it's what I expect it to be.
What would you expect? Do you do anything after you have
folder
?FirstOrDefault() either returns a default value or the first element.
If you don't do anything with it afterwards, nothing will happen. An application which runs to its end terminates automatically.
Relating to your update: are you sure you are debugging the latest source files? Try to do a rebuild, see whether the compiled files and the debug files are updated.