使用亚音速T4模板从多个表中删除相关记录

时间:2009-11-27 01:27:44

标签: transactions subsonic delete-record

使用模板,如何从事务中的多个表中删除相关记录?

1 个答案:

答案 0 :(得分:2)

using (TransactionScope transactionScope = new TransactionScope())
{
  using (SharedDbConnectionScope sharedConnectionScope = new SharedDbConnectionScope())
  {
    new SubSonic.Query.Delete<Person>(new MyDB().Provider)
      .Where(PersonTable.IdColumn).IsEqualTo(1)
      .Execute();

    new SubSonic.Query.Delete<Basket>(new MyDB().Provider)
      .Where(BasketTable.IdColumn).IsEqualTo(1)
      .Execute();

    transactionScope.Complete();
  }
}