Domanda

Utilizzando i modelli, come posso eliminare i record correlati da più tabelle in una transazione?

È stato utile?

Soluzione

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();
  }
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top