Is there any difference between these ways of using/try-catch blocks?
First :
public bool Insert(SomeEntity entity)
{
bool result = false;
try
{
using (var db = new MyEntities())
{
db.AddToSomeEntity(entity);
db.SaveChanges();
result = true;
}
}
catch (Exception e)
{
//
}
return result;
}
Second :
public bool Insert(SomeEntity entity)
{
bool result = false;
using (var db = new MyEntities())
{
try
{
db.AddToSomeEntity (entity);
db.SaveChanges();
result = true;
}
catch (Exception e)
{
//
}
}
return result;
}
Does it affect performance?
This string was added in order to satisfy SO submit validation rule.