PDA

View Full Version : سوال: SqlTransaction در EF



sadaf_
دوشنبه 07 مرداد 1392, 22:43 عصر
اگر بخواهیم از SqlTransaction در EF استفاده کنیم
چطوری باید کدنویسی کرد

ممنون

esafb52
سه شنبه 08 مرداد 1392, 02:46 صبح
اینجوری
using (var context = new BlahEntities())

using (var tx = context.BeginTransaction())
{
// do db stuff here...
try
{
tx.Commit();
}
catch (Exception)
{

tx.rollback();
}

}
البته خودم استفاده نکردم
اینجا رو ببین
:http://stackoverflow.com/questions/1054980/how-to-use-transactions-with-the-entity-framework?rq=1