K
Kevin Frey
One of my chief criticisms of validators in an ASP.NET page is that they can
result in a developer re-implementing much of the "business logic" of a
transaction at the page level.
Assuming we have an object that implements business logic, and that object
is utilised via an ObjectDataSource, I wish to enquire what the correct
method is for handling errors from the business logic object.
For example, there are some circumstances where a transaction cannot be
completed due to a validation error. But for the sake of this discussion,
and to remove any potential for using a "Validator" in a pre-validation
sense, let's assume the "validation error" is due to a
transaction-time-determined consistency-related operation such as an
organisation exceeding their credit limit at the time of placing an order.
Clearly in a multi-user system such a test can only be performed when the
operation is being committed to the database, because otherwise it is
[potentially] subject to violation.
So, with a view to "best practices implementation", how should my business
logic object report such an error? Throw an exception?
And how should my page react to such an exception? Should I be hooking event
handlers onto the Inserted, Deleted (etc) events of ObjectDataSource and
then interrogating the ObjectDataSourceStatusEventArgs object for the
presence of an Exception?
If there is an exception, what would a typical course of action be? Would it
be feasible to somehow inject a message into a ValidationSummary control?
Many thanks
Kevin
result in a developer re-implementing much of the "business logic" of a
transaction at the page level.
Assuming we have an object that implements business logic, and that object
is utilised via an ObjectDataSource, I wish to enquire what the correct
method is for handling errors from the business logic object.
For example, there are some circumstances where a transaction cannot be
completed due to a validation error. But for the sake of this discussion,
and to remove any potential for using a "Validator" in a pre-validation
sense, let's assume the "validation error" is due to a
transaction-time-determined consistency-related operation such as an
organisation exceeding their credit limit at the time of placing an order.
Clearly in a multi-user system such a test can only be performed when the
operation is being committed to the database, because otherwise it is
[potentially] subject to violation.
So, with a view to "best practices implementation", how should my business
logic object report such an error? Throw an exception?
And how should my page react to such an exception? Should I be hooking event
handlers onto the Inserted, Deleted (etc) events of ObjectDataSource and
then interrogating the ObjectDataSourceStatusEventArgs object for the
presence of an Exception?
If there is an exception, what would a typical course of action be? Would it
be feasible to somehow inject a message into a ValidationSummary control?
Many thanks
Kevin