【问题标题】:Delete related records from multiple tables using subsonic T4 templates使用亚音速 T4 模板从多个表中删除相关记录
【发布时间】:2009-11-27 01:27:43
【问题描述】:

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

【问题讨论】:

    标签: transactions subsonic delete-record


    【解决方案1】:
    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();
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多