Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can't run query from inside a transaction?
Message
De
07/09/2004 12:35:33
Max Fillmore
Essential Skills, Inc.
Lenexa, Kansas, États-Unis
 
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
00938776
Message ID:
00940016
Vues:
42
Thanks, Kevin, but what I'm looking for here is a framework solution. It seems to me that there is a hole in your framework that needs to be plugged. To be specific:

It often occurs that a table will have a unique constraint which requires that a single column or combination of columns in the table will be unique within the table. For example my customer table may use an identity column, CustomerId, as the primary key but an affiliated company may use a distinct 5 letter CustomerCode to represent the customer in a separate database. Rather that add a separate table for the affilliated customer we simply add the CustomerCode column to the Customer table and establish a unique constraint on CustomerCode. Conceptually it is much easier for the users to undersand. Surely I am not the only one who has to deal with this type of situation.

When I save a Customer row I need to establish that the CustomerCode is unique so that I don't get an unhandled exception back. I would like to do this from inside the CheckRulesHook() so that I can add a BrokenRule and an ErrorProviderBrokenRule and take advantage of this mechanism to indicate to the user what is wrong. Because I want to do all database io from the business object I would code a GetCount() method in the business object that queries the database for a count of Customer rows with the passed CustomerCode by passing a "SELECT COUNT(*)..." command to ExecScalar(). I call this from the CheckRulesHook inside the BusinessRules object. Also because I am saving a Parent and Child business objects I want to use the AutoTransaction. The problem is that I don't know how to get the transaction handle that was created by SaveData() when saving the parent business object and I don't know how I would use it use it in my GetCount() method since ExecScalar has no overload which takes an IDbTransaction.

It is my contention that your framework should take care of this by default. In other words the methods in mmBusinessObject which interact with the database, GetDataSet(), ExecScalar(), etc., should detect if the bizobj is a CHILD business object and if so it should check whether or not its parent business object is involved in a transaction. If it is, the child bizobj should retrieve and use the transaction handle from the parent.

Does this make sense to you? Will you add this feature to the framework?

If not can you give me some code or an outline of how to code it so I can help myself out here?

Thanks,
Max...
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform