我想做这个:
create procedure A as
lock table a
-- do some stuff unrelated to a to prepare to update a
-- update a
unlock table a
return table b
Run Code Online (Sandbox Code Playgroud)
有可能吗?
最后,我希望我的SQL服务器报告服务报告调用过程A,然后只在过程完成后显示表a.(我无法更改程序A以返回表格a).
我正在使用Entity Framework 4.0.现在我需要限制对表的访问,当我从中读取或写入时.可能是关于事务隔离级别的.
我怎么做?
更新
这就是我所拥有的
using (var db = new MyDb())
{
using (TransactionScope scope = new TransactionScope())
{
var item = db.MyItems.Single(x => x.Id == 5);
item.Price = 12;
db.SaveChanges();
scope.Complete();
}
}
Run Code Online (Sandbox Code Playgroud)
但是,当我在内部的任何一行放置一个断点时using (TransactionScope scope,当我停在那里然后我去了Sql Server Management Studio并从一个在事务中使用的表做一个select查询(甚至更新!),我因某些原因没有收到错误.但为什么?它必须不允许我在执行事务时读取数据.