I get a Exception type using
catch(Exception e){
log.Error(e.GetType()); // it write 'System.Data.EntityException'
}
so I change my code to catch that exception,
try{
...
}catch(EntityException a){
// need to do something
log.Error("I got it!");
}catch(Exception e){
log.Error("No");
}
and the code write only “No”.
How can I catch the EntityException before reach Exception?
Thanks
The code you have should work correctly, provided there isn’t another
EntityExceptiontype defined within the current set of using statements for that file or namespace.Try fully qualifying the type, as in the following: