Click here to Skip to main content
Click here to Skip to main content

WCF by Example - Chapter XIV - Validation & Exception Management

By , 25 Oct 2012
 
Previous Next
Chapter XIII Chapter XV

The Series

WCF by example is a series of articles that describe how to design and develop a WPF client using WCF for communication and NHibernate for persistence purposes. The series introduction describes the scope of the articles and discusses the architect solution at a high level. The source code for the series is found at CodePlex.

Chapter Overview

This is a two part chapter that covers the validation in WPF views and the management of business exceptions and warnings in the client side. For the validation topic, we will discuss how to provide comprehensive validation functionality all the way from the UI layers back to the server side, for the warnings and exceptions, the application will provide a customised exception handling mechanism for both client exceptions and business exceptions returned by the server methods; for the business notifications we will put in place a nice and slick notification feature that uses balloon notification messages in the Windows Task Bar.

Validation - DTO Implementation

We haven't covered validation in WPF in the series so far, maybe the reason for so it is to do with the fact that WPF validation is not that straight forward. We are going to describe what we consider to be a comprehensive solution given our application design. The eDirectory's solution is a hybrid one where a rich UI experience is provided but the validation code is not placed in the business entity, instead the DTO class is used for that purposes. In a nutshell, the following is an example of the type of validation functionality that is achieved in this manner:

In order to provide the above functionality, the following steps are required:

  • The DTO class needs to inherit from a new base class: ValidatorDtoBase
  • DataAnnotation attributes are added to the DTO properties for validation purposes
  • XAML Binding needs to be amended with the following:
    1. Mode = TwoWay
    2. ValidatesOnDataErrors = True
    3. Validation.ErrorTemplate is set to the validationTemplate
  • Command buttons can bind to the IsValid property in the DTO for enabling/disabling purposes

As an example of how the DTOs will look after the above indicated changes, the CustomerDto looks like:

And the following is a section of the XAML that was changed:

And the last change is in the ViewModel so the Save button is enabled only when there are no validation errors:

Validation Design Discussion

Before we continue, let's stop for a second to discuss what goals we tried to achieve with the above mentioned solution:

  • Follow the DRY principle
  • Easy to test
  • It should be possible to execute the validation both in the server and the client side

Regarding the DRY principle, on paper, the business entity should be responsible for the business validation, in the case of the eDirectory Customer class, for example, the First Name field is not nullable and cannot be longer than 50 chars. This is a classic example of validation that should be defined on the entity itself. It is feasible placing this validation on the entity but it generates a sort of crude validation solution where the client needs to call the server to find out if there is validation errors. On some projects, this is acceptable and it may result in being the best approach as it facilitates testing and rapid development.

The eDirectory application proposes a solution where simple validation can be declared in the DTO object so WPF validation can be used in the client side, the entity can also use this validation in the server side. We are basing this solution in the following articles:

Attributes-base Validation in a WPF MVVM In this article, the IDataErrorInfo interface is used in combination with validation attributes in the ViewModel classes. We used the logic in the back-end to retrieve validation attributes and getters using LINQ queries. This concept was originally covered on the WPF Validation with Attributes and IDataErrorInfo in MVVM post
Automatically validating business entities in WPF using custom binding and attributes This is an interesting article by Sandrino Di Mattia based on the work done by Phillipp Sumi on WPF custom binding. In this solution, a custom WPF binding is used for validation purposes, the eDirectory solution is very similar but it is developed around standard classes without requiring additional implementation. Still, it is a very good article.
Validation in Windows Presentation Foundation This is a four year old article that still applies, it is surprising how little things have changed since then, maybe Microsoft is trying to say to all of us that is time to move to the mighty Silverlight Smile
Implementing Data Validation in Silverlight with INotifyDataErrorInfo This article covers the use of INotifyDataErrorInfo in Silverlight. It is a good article, discussing the limitations of the IDataErrorInfo interface and covering some of the internals of how controls interacts with the validation code.

Before we move on, if you are one of those that like DDD and find it frustrating to locate the validation outside the business entities, it may be the time to look at frameworks that resolve this type of issue in a better way:

IDataErrorInfo & Validation Attributes Implementation

The eDirectory solution is based on the proposed idea on the WPF Validation with Attributes and IDataErrorInfo interface in MVVM post and it states:

WPF provides validation infrastructure for binding scenarios through IDataErrorInfo interface. Basically, you have to implement the Item[columnName] property putting the validation logic for each property in your Model (or ModelView) requiring validation. From XAML, you need to set ValidatesOnDataErrors to true and decide when you want the binding invoke the validation logic (through UpdateSourceTrigger). Then idea is to generalize the validation logic in IDataErrorInfo.Item[] using the validation attributes in System.ComponentModel.DataAnnotations assembly.

So we can have a new base class that inherits from DtoBase and implements the IDataErrorInfo interface so the WPF control can be notified if there was a validation error. The base class delegates to an instance of DataErrorInfo which is responsible for gathering the properties that are tagged with validation attributes and invokes the validation when the IDataErrorInfo methods are executed.

It is worth noting that both the ValidatorDtoBase and DataErrorInfo implement the IDataErrorinfo interface and that the first one merely delegates into the second class when the methods are invoked.

There is one aspect on this class that can be improved in terms of performance, your Dtos will not change at run time so it probably makes sense to store the validator and property maps the first time that they are created. This will result in a performance improvement although you will have to watch out for synchronization issues and locking.

Server Side Validation

As we indicated at the start of this chapter, one of our goals is to be able to check for validation errors at the server side as well. With the proposed solution, it is relatively easy to achieve this requirement. For example, when the Customer.Create method is invoked, the following code has been added:

The ValidateOperation method is declared in the base class: EntityBase, this method checks for validation errors in the DTO, throwing a business exception if any error is found:

XAML Error Templates

WPF provides very basic support for validation errors on the views, however with some few changes, we can provide a richer experience. Our solution provides three different mechanisms: red border around the textbox control, validation error symbol and tooltip.

For the red border and the validation error symbol, a control template was created named validationTemplate, for the tooltip a custom style was created for the TextBox control. Both declarations were added to Application.resources at the App.xaml file.

For the tooltip to be shown, no further action is required. However, we need to indicate in each control that we want to use the validationTemplate in the XAML. You may prefer to move this template to an style instead, the following article explains how to do it: IDataErrorInfo, Error Templates and WPF.

The XAML for the template and style is as follows:

Business Exception Management

We have covered in the previous chapters business warnings and exceptions in the server side, this section of this chapter covers for the client side, specifically how the client application notifies the user of those events. We are going to display a modal screen indicating the user of any exception and ensuring that the client application stops any processing. For the business warnings, instead, a notify icon will be available that will inform the user using info balloons on the Windows taskbar.

Trapping All Exceptions in a WPF Application

It is relatively easy to catch all unhandled exceptions in WPF:

The handler implementation creates a new Notifier view and sets the Handled property to indicate to the application that the exception was managed.

The view is quite simple, a left section for an image, the right panel is used for displaying the exception details. Couple buttons permit to copy the whole exception and call stack to the clipboard and close the window.

There is nothing special regarding the new view and controller that we haven't seen before:

At this point, we have a new mechanism that ensures all exceptions are well managed, for example, if an exception was to be generated during the client processing, the following screen is displayed:

Business Exceptions - Client Implementation

We need to leverage the new ExceptionNotifier with the Business Exceptions retrieved from the server responses. In first place, we need to revise the code at the ServiceAdapterBase class, the ExecuteCommand is the correct location for adding the new functionality. Currently the method looks like:

We just need to call the new ExceptionNotifier implementation, a first implementation could be something as follows:

We don't need to explain why an ExceptionNotifierViewModel instance is created, however the next line is critical in the implementation. Without it, the client does not know that an exception took place when calling the server, throwing an exception ensures that the client processing is halted. The SuspendProcessException is needed as the following changes are done to the Application Dispatcher Unhandled Exception method:

Dependency Injection - Testing Implementation

After the above changes, if we execute the tests we notice that all of them are passing. The fact is that our coverage is not that good; we need a new test that causes a server business exception. The "CreateDuplicate" test does exactly so, if the test is executed the following window is displayed:

This is obviously a problem, DI can help to resolve this issue. We need to encapsulate the business exception handling on a sort of abstract service and then provide a different implementation when the tests are executed. We need to take the following steps:

  • Create a new interface: IBusinessExceptionManager
  • Amend the ClientServiceLocator so an instance of the new interface is exposed
  • Use the new exposed interface in the ServiceAdapterBase ExecuteMethod
  • Create a new implementation of the new interface: BusinessException Manager
  • Add another implementation of the interface on the Test project
  • Modify Spring.Net configuration files

So the ServiceAdapterBase now looks like:

The client implementation then is:

The test implementation then is:

Now, if the tests are executed, all of them pass including the new one:

Business Warning Management

We now have a comprehensive mechanism for managing application and business exceptions, but we also need to work out a way for notifying for business warnings. Having dialog windows for warnings could annoy users, so instead we will use a sort of balloon notification running on the Windows Task Bar. For this purpose, we are using the WPF NotifyIcon project. The following steps are required to provide this functionality:

  • Create a new interface: IBusinessWarningManager
  • Add a new service WarningManager to the ClientServiceLocator class
  • Change the ServiceAdapterBase class so it uses the new service
  • Create new BusinessWarningManager class
  • Amend the Spring.Net configuration file to setup the WarningManager

The BusinesswarningManager implementation is as follows:

It is worth noting how relatively easy is to invoke the TaskbarIcon in the above code. Then we need to change the ServiceAdapterBase to invoke the new method in the BusinessWarningManager:

When a notification is received on the client side, a notification is automatically displayed on the Windows Taskbar:

As we saw with the exception manager, we need a test implementation of the warning manager:

Chapter Summary

Validation in WPF could be cumbersome sometimes, in this chapter a comprehensive solution using Validation attributes was presented that permits to execute the same validation both in the client and server side thus providing easy testing even when the validation logic is not located at the business entities.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Enrique Albert
Software Developer (Senior)
Ireland Ireland
No Biography provided
Follow on   Twitter

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Questionasp.net MVC project examplememberJose Campos11-Apr-12 12:21 
Do you have a asp.net MVC project example instead of WPF?
 
In the meantime, your solution is excellent.
AnswerRe: asp.net MVC project examplememberEnrique Albert11-Apr-12 13:27 
I am currently working on a new article that explains how to re-use the server components in the case of developing an MVC application. I'll let you know when is ready, I guess it would take me at least 10 days before it is ready (I am quite busy at the moment).
 
Thanks.
AnswerRe: asp.net MVC project examplememberEnrique Albert15-Apr-12 6:38 
Hi Jose,
 
I have uploaded a new branch in CodePlex with a solution that contains a MVC 3 project as you requested. It is in a sort of a Beta version -- it needs a little bit more work on the warning/error handling. I dont think I will have too much time the next days so I thought you'd like to get access to a preview of the code. A new article should be available in the next few weeks.
 
Thanks.
 
links:
CodePlex -- Source Code[^]
Change Set -- MVC Branch[^]
GeneralMy vote of 5membermanoj kumar choubey27-Mar-12 21:24 
Nice
QuestionException handlingmemberVishwanathBK26-Mar-12 19:09 
Dear Enrique,
 
I have found that, the error handling done only in ExecuteCommand method of eDirectory.Domain project. Is it not required to have try catch blocks in other methods/other projects ?
 
I saw there is one ExceptionNotifierView which is used to display the unhandled exception, just wanted to know is this view displayed for any type of unhandled exception?
 

Regards
Vishwanath
Vishwanath

AnswerRe: Exception handlingmemberEnrique Albert27-Mar-12 4:22 
VishwanathBK wrote:
I have found that, the error handling done only in ExecuteCommand method of eDirectory.Domain project. Is it not required to have try catch blocks in other methods/other projects ?

No, it is not required. In the domain, please do not catch exceptions, if you do, then you will need to managed the transaction instead of having the Transaction Manager to do for you.
 
VishwanathBK wrote:
I saw there is one ExceptionNotifierView which is used to display the unhandled exception, just wanted to know is this view displayed for any type of unhandled exception?

Yes, in the UI side, you do't need to catch exceptions as the application will nicely catch them for you.
GeneralHats off - 5/5membersreejith ss nair14-Jan-12 14:09 
Good work.
Sreejith S S Nair
 
"Everything that can be invented has been invented."
Charles H. Duell, Commissioner, U.S. Office of Patents, 1899

GeneralMy vote of 5membersreejith ss nair14-Jan-12 14:08 
I must admit. Great Job. Hatsoffs for the consistent work, dedication, and most importantly time which you spend. 5/5
GeneralRe: My vote of 5memberEnrique Albert15-Jan-12 22:44 
Thanks, I appreciate.
GeneralMy vote of 5membertoantvo24-Aug-11 16:45 
Hi Enrique,
 
Your series are very good. You got 5 from me. I wonder do you have any idea about data concurrency locking? Which kind of lock should be used as optimistic or pessimistic lock?
GeneralRe: My vote of 5memberEnrique Albert7-Sep-11 2:46 
Hi,
 
apologies for the delay, I just saw your question. Simple answer, I just use the default isolation level, in SQL Server SELECT statements are locked by CRUD operations where ORACLE does not. You could leverage difference isolation levels depending the scenario but it requires to expose this functionality in your architecture which I'd say it is an overhead to say the least.
 
In NHibernate, instead, you can use the Versioning function to ensure that your instance version in memory matches to the one stored in the database. I would recommend to use this approach for the problem that you mention.
 
Why dont you have a look at the following article:
http://ayende.com/blog/3946/nhibernate-mapping-concurrency[^]
 
Thanks
QuestionWCF CallbacksmemberMikaelHild5-Aug-11 1:53 
Hi Enrique,
I just love your series because you really teach good with your articles!
 
Im somewhat fairly new to developing in C# and I have been reading your articles for some time to learn better ways of structuring my code and implement better patterns.
 
I would really appreciate feedback on how you would implement WCF callback in this design, where the server would message the clients for e.g. new available data, server maintenance or similair. Would that be possible?
 
Again, thank you for your contribution and I hope you will continiue the series!
AnswerRe: WCF CallbacksmemberEnrique Albert7-Aug-11 17:05 
Hi,
 
MikaelHild wrote:
I would really appreciate feedback on how you would implement WCF callback in this design, where the server would message the clients for e.g. new available data, server maintenance or similair. Would that be possible?

Sure, you can use the dual http binding in WCF. It is not straight forward but we had it working in an sort of notification/monitoring system in the last project that I was working.
You may want to search for "dual wcf", have a look at the following article: WCF Duplex, SMS, a WebServer and a Windows Client (and a couple of other things)[^]
 
Thanks for the feedback
QuestionFew questions.. [modified]memberMember 195080930-May-11 17:41 
Hi Enrique,
 

Thanks for the wonderful series of article.
 
I have two questions
 
1. Is there any way to generate the "hbm.xml" file, because I am not certain about this.
 
2. I have tried to use the source code and tried to add a new screen called "Department" and I am able to add a record and display it in the grid. During the development, I have
I found that the logic is very robust and very nicely handled. I have one question, to develop this I had to add more than 10 new files and need to modify 7 existing files.
So in an enterprise application (where atleast 50-60 screens), this will be difficult to handle it. Of cource, one should get hold of the concepts. I was just wondering, any way to cut this short.
 
3. May I know the design considerations to use NHibernate rather Entity Framework?
 

Also, I am awaiting for your new articles in this series.
 
Regards
Vishwanath

modified on Friday, June 3, 2011 5:34 AM

AnswerRe: Few questions..memberEnrique Albert28-Jul-11 19:56 
Apologies for coming back this late, I completely missed this entry.
 
1 - I am aware of a modeling tool that the provides the hbm file: Llblgen Pro[^]. You can also have a look at Fluent Nhibernate[^] or Fabio Maulo's mapping-by-code[^]
 
2 - You are right, the number of files are something to consider, the client side ones smell a little too bad. I have considered using AOP or even templates for RAD purposes. But it is a little price to pay for the comprehensive flexibility for development and testing that it is achieved.
 
3 - I have used EF for prototyping purposes only, I always prefer NHibernate because its maturity and flexibility; it also provides the functionality I want in a non-intrusive manner.
 
Thanks for the feedback.
AnswerRe: Few questions.. [modified]memberEnrique Albert6-Oct-11 2:48 
Hi again,
 
regarding your 2nd point, you were right. I have developed a new implementation that drastically reduces the number of required classes to implement in the client side, in fact, with the new design, when a new contract or method is added to the server side, nothing needs to be added to the client.
 
I am still working in the re-factor and it could take me a while before I can publish the articles. I'll let you know when is ready.
GeneralRe: Few questions.. [modified]memberVishwanathBK9-Oct-11 5:24 
Thank you so much for considering my feedback. Eagerly waiting for the new version..
Vishwanath

GeneralRe: Few questions.. [modified]memberEnrique Albert9-Oct-11 15:48 
The latest code in Codeplex[^] contains the re-factor that I mentioned before. The client does not need to implement any service contract interface anymore. I think the new design is more in line with what you were expecting.
 
I am working on the articles, but I guess that is going to take a lot more time that the re-factor itself.
 
Regards,
Enrique
QuestionQuestion on validationmembertyzh24-Mar-11 9:13 
My application consists of a web calling a WCF service, then Entity Framework, etc, so some details are slightly different. Since all my queries have to be authorized and audited, I created a common request object pass in to every service call. For example
 
public LatestOrder GetLatestOrder(CustomerRequestDto request);
 
To validate input, I have CustomerRequestDto:ValidatorDtoBase. The problem is, by passing in CustomerRequestDto as a parameter, it seems bypass the ValidatorDtoBase constructor, so when I call request.IsValid() in the service, it got an object null reference error when the code reaches
 
return DataErrorValidator.Error;
 
If I create a new copy of the CustomerRequestDto request2, then do request2.IsValid(), it works fine.
 
What did I miss? Thanks
AnswerRe: Question on validation [modified]memberEnrique Albert24-Mar-11 23:06 
I am not sure but it seems to me that you are having a serialization issue; are you using exactly my base classes or yours are customized. If so, watch out for WCF serialization issues.
 
I have tested my code again and I cannot replicate the problem you mentioned. Can you post the call stack when the exception takes place?
modified on Friday, March 25, 2011 10:02 AM

GeneralRe: Question on validationmembertyzh25-Mar-11 5:50 
Thanks for the update. I figured out where the problem is, but not quite sure about the solution.
 
My web front does not have a direct reference to the Common name space, only a reference to the WCF service WSDL. In this case, when I create a CustomerRequestDto, it does not go through the constructor in ValidatorDtoBase. So DataErrorValidator is null when calling IsValid.
 
Is this the serialization issue you refer to? When I make a direct reference to Common, it does go through base constructor, but I can't have both the project reference and service WSDL. Is there a way to serialize the ValidatorDtoBase and make its constructor available on the client side?
 
Another workaround I tried is to remove the readonly and create the DataErrorValidator as needed, as shown here. But I'm not sure if this is what you intended and has any side effect.
    public abstract class ValidatorDtoBase
        : /*DtoBase,*/ IDataErrorInfo  {
        private /*readonly*/ DataErrorInfo<ValidatorDtoBase> DataErrorValidator;
 
        protected ValidatorDtoBase()  {
            DataErrorValidator = new DataErrorInfo<ValidatorDtoBase>(this);
        }
 
        public bool IsValid()  {
            if (DataErrorValidator == null)
                DataErrorValidator = new DataErrorInfo<ValidatorDtoBase>(this);
 
            return string.IsNullOrEmpty(Error);
        }
 
BTW, some other changes I made that may or may not be relevant. I don't have the static Create as in your example. Also skip the TransactionManager. All validation and exception are handled in service layer, results are added to DtoResponse. I also leave only BusinessException (Info,Validation, Critical, Fatal) and no warnings in the response instance. Not as elegant as your original but with limited understanding and background knowledge, I couldn't adapt everything using Entity Framework.
GeneralRe: Question on validation [modified]memberEnrique Albert25-Mar-11 14:50 
Thank you for spotting the bug. You solution is correct but it needs to be implemented in each public method. There are couple ways to resolve the issue. One is to add a method to the class that is executed in the server side when the instance is deserializing:
 
    public abstract class ValidatorDtoBase
        : DtoBase, IDataErrorInfo 
    {
        private DataErrorInfo<ValidatorDtoBase> DataErrorValidator;
 
        protected ValidatorDtoBase()
        {
            DataErrorValidator = new DataErrorInfo<ValidatorDtoBase>(this);
        }
 
        #region Implementation of IDataErrorInfo
 
        ...
 
        #endregion
 
        public bool IsValid()
        {
            ...
        }
 
        [OnDeserializing]
        internal void OnDeserializingMethod(StreamingContext context)
        {
            DataErrorValidator = new DataErrorInfo<ValidatorDtoBase>(this);
        }
    }
 
You can see I am leaving the constructor behind for RAD purposes where I don't want to deploy the web services when I am developing. You may question the above approach, instead you may prefer a more explicit way, something like:
 
   public abstract class ValidatorDtoBase
        : DtoBase, IDataErrorInfo 
    {
        private DataErrorInfo<ValidatorDtoBase> DataErrorValidator;
 
        #region Implementation of IDataErrorInfo
 
        public string this[string propertyName]
        {
            get { return GetDataErrorInfo()[propertyName]; }
        }
 
        public string Error
        {
            get { return GetDataErrorInfo().Error; }
        }
 
        #endregion
 
        public bool IsValid()
        {
            return string.IsNullOrEmpty(Error);
        }
 
        private DataErrorInfo<ValidatorDtoBase> GetDataErrorInfo()
        {
            if (DataErrorValidator != null) return DataErrorValidator;
            DataErrorValidator = new DataErrorInfo<ValidatorDtoBase>(this);
            return DataErrorValidator;
        }
    }
I have found that the issue also applies to the DtoBase class with the Response reference, but this is not a problem because this reference is never updated in the client side. I will update the code in CodePlex with the above changes.
 
Thanks again.
modified on Saturday, March 26, 2011 3:29 AM

GeneralRe: Question on validationmemberEnrique Albert25-Mar-11 22:26 
tyzh wrote:
My web front does not have a direct reference to the Common name space, only a reference to the WCF service WSDL.

 
If you are using the validation approach then you are using the Validation Attributes on the DTO. The WSDL proxy will not provide those at the client side which means you can only use server side validation. If you are just invoking web methods synchronously (MVC or ASP.NET), I suggest to have a reference to the Common assembly. The code for creating WCF proxies is relatively straight forward:
 
            var dto = new CustomerDto {FirstName = "Joe", LastName = "Bloggs", Telephone = "99-0000"};
            CustomerDto response;
            using (var factory = new ChannelFactory<ICustomerService>("BasicHttpBinding_ICustomerService"))
            {                
                try
                {
                    var proxy = factory.CreateChannel();
                    response = proxy.CreateNewCustomer(dto);    
                }
                finally
                {
                    factory.Abort();
                }                
            }
            return response;
 
And the endpoint declaration in the web.config is:
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                ...
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:40003/CustomerWcfService.svc/CustomerServices"
                      binding="basicHttpBinding" 
                      bindingConfiguration="BasicHttpBinding_ICustomerService"
                      contract="eDirectory.Common.ServiceContract.ICustomerService" 
                      name="BasicHttpBinding_ICustomerService" />
        </client>
    </system.serviceModel>
 
This approach ensures that the client and server are always in sync and reduces duplication if validation must take place on the server and client side.
GeneralRe: Question on validationmembertyzh30-Mar-11 9:33 
I intended to share the Common assembly and client-side validation. But by adding service reference first, it generates all the classes and I never had the direct reference. After removing all reference and add them back in the right order, all is fine now. Although we wouldn't have this conversation if it started that way.
 
Thanks for the great work and all the help.
QuestionQuestion about Exception, Warning, TransactionManager and DtoResponse, etc.membertyzh22-Jan-11 9:14 
Still trying to figure out how things work. My understanding so far is
 
- Service adds warnings through Container.RequestContext.Notifier
- Entity validation simply throws BusinessException
- Transaction manager either catch the exceptions or add warnings from above.
 
What I'm trying to understand are:
 
- Only warnings are added through notifier, and exception are just throw and catch, right?
 
- What happens to system exception, like network or database time out or other unhandled exception? Can you catch and add them as regular business exception, or better just a simple throw?
 
- Transaction manager is the one that assemble all the information and pass it back up the chain, right? And it does this through the repository locator and dto parameters in ExecuteCommand?
 
- We have many situations where a simple query also need to be audited and maybe other actions taken. Do I need to treat those as transactions? Are there an equivalent of ExecuteQuery that I can pass in locator, CustomerDtos and hide the exception handling away from service layer? Of course if Query/Auditing should not be treated as transaction, then it's a different story.
 
- What's the advantage of having separate warning and exception? They seem very close. What if I have an exception with type Informational/Warning/Validation/Critical/Fatal, will that be able to accomplish both? Since warnings are added in service, I can just add an exception with type Informational/Warning. Or are there any situation I haven't considered?
 
- In my case, I have a separate business domain and two application services. Where should I put the AppServices? Sounds like they belong to service layer, but you don't want to duplicate the code. In Common?
 
- Am I asking too much and should go back and pick up an OOP 101? D'Oh! | :doh:
 
Thanks

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130617.1 | Last Updated 25 Oct 2012
Article Copyright 2011 by Enrique Albert
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid