Entity Framework 摘记
1.设置隔离级别
var transactionOptions = new System.Transactions.TransactionOptions(); transactionOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted; using (var transactionScope = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required, transactionOptions)) { using (var context = new MyEntityConnection()) { } transactionScope.Complete(); }
2.更新数据
db.Product.Attach(model); db.Entry(model).State = System.Data.EntityState.Modified; db.SaveChanges();
桂棹兮兰桨,击空明兮溯流光。