Re: TableAdapters and Transactions again!
- From: "Sahil Malik [MVP C#]" <contactmethrumyblog@xxxxxxxxxx>
- Date: Wed, 25 Oct 2006 10:33:37 -0400
OK. I thought I could loop through a dictionary collection of say
'ITransTableAdapter' interfaces. The business layer can add all the TAs in
and then call them by the key once they have been enlisted in the
transaction.
Yep that sounds awrite. (Also see a comment about DbConnectionScope below).
Can I start a transaction on the first adapter in the loop and then pass
it to each subsequent adapter in the collection?
Yeah that should work out just fine.
Can you give me an idea of how the EnlistInTransaction method might look?
It should be very similar to a single table adapter scenario; take in a
transaction object, and a connection object. The connection needs to be
open.
BTW - Alazel Acheson from the MSFT ADO.NET team once blogged about something
called DbConnectionScope; (just search on it), he used an interesting design
pattern that you may find useful as well. His stuff was specific to Sys.Tx
though; but no reason why you couldn't use the same paradigm.
- Sahil Malik [MVP]
http://blah.winsmarts.com
"J055" <j055@xxxxxxxxxxxxxxxxx> wrote in message
news:%23$ux$BE%23GHA.4388@xxxxxxxxxxxxxxxxxxxxxxx
Hi
I hope you like the book - even though I've advocated against
TableAdapters in Chapter 3 :) for the very reasons you are running into.
Yes, the lack of support for transactions has caught me out a bit.
Anyway, the idea of factory would be something as simple as creating an
EnlistInTransaction method on each TableAdapter. You could then have each
TableAdapter implement a specific custom interface, and then you could
create a class on top that calls EnlistInTransaction for every instance
of that interface passed in.
OK. I thought I could loop through a dictionary collection of say
'ITransTableAdapter' interfaces. The business layer can add all the TAs in
and then call them by the key once they have been enlisted in the
transaction.
Can I start a transaction on the first adapter in the loop and then pass
it to each subsequent adapter in the collection? Can you give me an idea
of how the EnlistInTransaction method might look?
Does this sound reasonable? It's a bit messy using keys but I can't think
how else to do it.
I think it's starting to look like a workable plan. Your comments will be
very much appreciated.
Thanks again
Andrew
.
- Follow-Ups:
- Re: TableAdapters and Transactions again!
- From: J055
- Re: TableAdapters and Transactions again!
- References:
- TableAdapters and Transactions again!
- From: J055
- Re: TableAdapters and Transactions again!
- From: Sahil Malik [MVP C#]
- Re: TableAdapters and Transactions again!
- From: J055
- Re: TableAdapters and Transactions again!
- From: Sahil Malik [MVP C#]
- Re: TableAdapters and Transactions again!
- From: J055
- TableAdapters and Transactions again!
- Prev by Date: TableAdapter - Refresh the data table option
- Next by Date: Re: DataSet help -- .Merge() & .GetChanges()
- Previous by thread: Re: TableAdapters and Transactions again!
- Next by thread: Re: TableAdapters and Transactions again!
- Index(es):
Relevant Pages
|