当我使用此代码时有什么区别:
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;
}
还有这个:
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;
}
会影响性能吗?
/添加此字符串是为了满足 SO 提交验证规则。/