读书人

找不到Connection.CreateConnectionSc

发布时间: 2012-03-20 14:01:10 作者: rapoo

找不到Connection.CreateConnectionScope(),命名空间是什么?
提示:System.Data.Common.DbConnection 不包含 CreateConnectionScope

C# code
using (var dbtran = new TransactionScope(TransactionScopeOption.Required))            {                using (var t= new TestEntities())                {                     using (t.Connection.CreateConnectionScope())// EF Extension中的扩展方法,作用是open connection并在dispose里释放它                    {                                                 t.AddToTableA(t1);                            t.SaveChanges();                            var cmd = t.CreateStoreCommand("update form set xxx=xxx where formid=2", CommandType.Text);          cmd.ExcuteNonQuery();                            dbtran.Complete();                      }      }    }


[解决办法]
using Microsoft.Data.Extensions;

http://archive.msdn.microsoft.com/EFExtensions/Release/ProjectReleases.aspx?ReleaseId=3624

读书人网 >.NET

热点推荐