Friday, March 09, 2007

Robust Coding with CBO's and Hydrator

I thought of giving some of my thoughts on DAL and BL designing. Some buzz words today among designers are DTO's and Business Objects (BO's). DTO Vs BO discussion is somewhat controversy and I'm not going to touch that here :). DTO's are smiler to CBO's (Custom Business Objects) that I'm talking in this article.

First I'll refer to a Framework that use CBO's and hydrator design pattern. DotnetNuke is a open source Content Management and Portal development framework (http://www.dotnetnuke.com/). It has a large community and fairly stable product. We have used this for couple of commercial products and customers are happy so do we. The complete data layer of this solution is built on CBO's and a Hydrator. This greatly reduces the size of the code and it's complexity.

If you are using CBO's in your code just think how are you going to populate those objects using a DaraReader. If you are going to hand code all the filling mechanisms definitely it's going to be a nightmare. Just think the the maintenance effort, if you change something in the data model you have to go and change the filling codes as well. You can greatly reduce this complexity by using a hydrator or a helper class with CBO's to automatically fill your CBO's based on reflection.

Few hints on how to write a flexible helper class (Hydrator)

  • Use .NET 2.0 Generics to define the FillCollection method

public static C FillCollection(Type objType, IDataReader dr)
where T : class, new()
where C : ICollection, new()

By using generics you can generalize the method to use custom return collections as well as to define concrete objects to be filled at compile time. What I love about this is you can specify generic constraint using where clause.

C# supports five different constraints:


  1. Interface constraint - The type argument must implement the specified interface.
  2. Inheritance constraint - The type argument must derive from the specified base class.
  3. Class constraint - The type argument must be a reference type.
  4. Struct constraint - The type argument must be a value type.
  5. New constraint - The type argument must expose a public, parameterless (default) constructor.

In the above
"where T : class, new()" means the object should be a reference type and it should have a parameterless constructor


  • Use Custom Attributes to map object properties to DB columns and to define custom values to null properties. So you don't have to use the same DB column names in your object properties and you can override default null values.
Download Code

75 comments:

Anonymous said...

I’d think about the the world of to spy that too!

Anonymous said...

Your blog is so informative … keep up the good work!!!!

Anonymous said...

great share, great article, very usefull for me...thank you

Anonymous said...

Maybe I`ll be Captain Obvious, but... it's only few days to New Year last, so let's be happy!
Hoho3ho!)

Anonymous said...

i actually selecting gather a lot of advantages.

Anonymous said...

It’s really a nice and helpful piece of information. I’m glad that you shared this helpful info with us. Please keep us informed like this. Thanks for sharing.

Anonymous said...

Yes, really.

Anonymous said...

Great information! I’ve been looking for something like this for a while now. Thanks!

Anonymous said...

[url=http://directlenderloansonlinedirectly.com/#kksjv]payday loans online[/url] - payday loans online , http://directlenderloansonlinedirectly.com/#eqgza payday loans online

Anonymous said...

[url=http://cialisdirectly.com/#kxefr]cheap cialis online[/url] - cialis online , http://cialisdirectly.com/#qfpor cheap cialis

Anonymous said...

[url=http://propeciadirectlyonline.com/#jehki]cheap propecia[/url] - propecia online without prescription , http://propeciadirectlyonline.com/#bjejo buy generic propecia

Anonymous said...

[url=http://buyaccutaneorderpillsonline.com/#16074]cheap accutane[/url] - order accutane , http://buyaccutaneorderpillsonline.com/#9681 buy accutane online

Anonymous said...

[url=http://buyaccutaneorderpillsonline.com/#14774]accutane cost[/url] - accutane cost , http://buyaccutaneorderpillsonline.com/#11826 accutane online without prescription

Anonymous said...

[url=http://buyaccutaneorderpillsonline.com/#19484]accutane without prescription[/url] - generic accutane , http://buyaccutaneorderpillsonline.com/#4709 order accutane

Anonymous said...

[url=http://buyaccutaneorderpillsonline.com/#14357]buy cheap accutane[/url] - accutane cost , http://buyaccutaneorderpillsonline.com/#18939 accutane no prescription

Anonymous said...

[url=http://buyonlinelasixone.com/#2183]lasix no prescription[/url] - cheap lasix , http://buyonlinelasixone.com/#13823 lasix no prescription

Anonymous said...

[url=http://buyonlinelasixone.com/#15095]lasix no prescription[/url] - lasix cost , http://buyonlinelasixone.com/#11449 generic lasix

Anonymous said...

[url=http://viagranowdirect.com/#etpmu]buy viagra online[/url] - viagra 100 mg , http://viagranowdirect.com/#sfeae viagra online without prescription

Anonymous said...

[url=http://buyviagrapremiumpharmacy.com/#sbowt]generic viagra[/url] - generic viagra , http://buyviagrapremiumpharmacy.com/#dzptr generic viagra

Anonymous said...

[url=http://buycialispremiumpharmacy.com/#fyfyb]cialis online[/url] - buy cialis , http://buycialispremiumpharmacy.com/#gkyei buy cialis online

Anonymous said...

[url=http://buyviagrapremiumpharmacy.com/#ojqlt]generic viagra[/url] - buy viagra online , http://buyviagrapremiumpharmacy.com/#pvdci buy cheap viagra

Anonymous said...

[url=http://buycialispremiumpharmacy.com/#rpixj]cialis online[/url] - buy cialis online , http://buycialispremiumpharmacy.com/#hggug generic cialis

Anonymous said...

[url=http://buyviagrapremiumpharmacy.com/#rxvca]buy viagra[/url] - viagra online , http://buyviagrapremiumpharmacy.com/#ylyah viagra online

Anonymous said...

[url=http://buycialispremiumpharmacy.com/#ljfpt]buy cialis online[/url] - buy cialis online , http://buycialispremiumpharmacy.com/#abhar buy cialis online

Anonymous said...

[url=http://buyviagrapremiumpharmacy.com/#nvagn]buy viagra online[/url] - buy cheap viagra , http://buyviagrapremiumpharmacy.com/#elcei buy viagra

Anonymous said...

[url=http://buycialispremiumpharmacy.com/#cxgka]buy cialis[/url] - buy cialis , http://buycialispremiumpharmacy.com/#bpylu cialis online

Anonymous said...

[url=http://buyviagrapremiumpharmacy.com/#cslot]generic viagra[/url] - buy viagra , http://buyviagrapremiumpharmacy.com/#jjmkv buy cheap viagra

Anonymous said...

[url=http://buycialispremiumpharmacy.com/#nakgq]cialis online[/url] - buy cialis , http://buycialispremiumpharmacy.com/#rgxgo buy cialis online

Anonymous said...

[url=http://buyviagrapremiumpharmacy.com/#ggbyz]generic viagra[/url] - generic viagra , http://buyviagrapremiumpharmacy.com/#amcfl buy cheap viagra

Anonymous said...

[url=http://buycialispremiumpharmacy.com/#wafzc]cialis online[/url] - buy cialis , http://buycialispremiumpharmacy.com/#eharm buy cialis online

Anonymous said...

[url=http://buyviagrapremiumpharmacy.com/#bxvbt]buy cheap viagra[/url] - generic viagra , http://buyviagrapremiumpharmacy.com/#yxvel buy viagra

Anonymous said...

[url=http://buycialispremiumpharmacy.com/#pqjmf]cialis online[/url] - buy cialis online , http://buycialispremiumpharmacy.com/#dpnhy generic cialis

Anonymous said...

[url=http://buycialispremiumpharmacy.com/#minxu]buy cialis[/url] - buy cialis online , http://buycialispremiumpharmacy.com/#mbvxy buy cialis

Anonymous said...

[url=http://buycialispremiumpharmacy.com/#jbjdu]buy cialis online[/url] - buy cheap cialis , http://buycialispremiumpharmacy.com/#hsyis generic cialis

Anonymous said...

[url=http://buyviagrapremiumpharmacy.com/#xcvcw]buy cheap viagra[/url] - buy cheap viagra , http://buyviagrapremiumpharmacy.com/#jjqny buy viagra online

Anonymous said...

[url=http://buycialispremiumpharmacy.com/#byewr]buy cialis[/url] - cialis online , http://buycialispremiumpharmacy.com/#shqkz generic cialis

Anonymous said...

[url=http://buyviagrapremiumpharmacy.com/#jxtxx]viagra online[/url] - buy viagra , http://buyviagrapremiumpharmacy.com/#fmpkw buy viagra online

Anonymous said...

[url=http://buyviagrapremiumpharmacy.com/#mlceh]buy viagra[/url] - generic viagra , http://buyviagrapremiumpharmacy.com/#seyxn buy viagra

Anonymous said...

[url=http://buycialispremiumpharmacy.com/#xgeyc]buy cialis[/url] - generic cialis , http://buycialispremiumpharmacy.com/#cosxp buy cialis

Anonymous said...

[url=http://buyviagrapremiumpharmacy.com/#eyeue]buy cheap viagra[/url] - buy viagra , http://buyviagrapremiumpharmacy.com/#unvgj buy viagra

Anonymous said...

[url=http://buyviagrapremiumpharmacy.com/#ipufa]buy viagra online[/url] - generic viagra , http://buyviagrapremiumpharmacy.com/#ftdiz buy viagra

Anonymous said...

[url=http://buycialispremiumpharmacy.com/#vpehg]generic cialis[/url] - generic cialis , http://buycialispremiumpharmacy.com/#eiwbh buy cialis online

Anonymous said...

[url=http://buyviagrapremiumpharmacy.com/#xusqa]buy viagra[/url] - generic viagra , http://buyviagrapremiumpharmacy.com/#qqqmu generic viagra

Anonymous said...

[url=http://buycialispremiumpharmacy.com/#vhqsb]buy cheap cialis[/url] - buy cialis online , http://buycialispremiumpharmacy.com/#qhdjs buy cialis online

Anonymous said...

[url=http://buycialispremiumpharmacy.com/#okopa]generic cialis[/url] - buy cialis , http://buycialispremiumpharmacy.com/#swrkd buy cialis

Anonymous said...

[url=http://buycialispremiumpharmacy.com/#uggtm]buy cialis[/url] - buy cialis , http://buycialispremiumpharmacy.com/#ztduw buy cheap cialis

Anonymous said...

[url=http://buyviagrapremiumpharmacy.com/#ulgpa]viagra online[/url] - viagra online , http://buyviagrapremiumpharmacy.com/#ksfsp buy viagra online

Anonymous said...

[url=http://buycialispremiumpharmacy.com/#oywtg]cialis online[/url] - buy cheap cialis , http://buycialispremiumpharmacy.com/#tvtmr buy cialis

Anonymous said...

[url=http://buycialispremiumpharmacy.com/#wowiz]buy cialis online[/url] - generic cialis , http://buycialispremiumpharmacy.com/#bkhtv buy cialis online

Anonymous said...

[url=http://buyviagrapremiumpharmacy.com/#oytzm]buy cheap viagra[/url] - buy viagra , http://buyviagrapremiumpharmacy.com/#splcp buy cheap viagra

Anonymous said...

[url=http://buyviagrapremiumpharmacy.com/#foeqe]buy viagra[/url] - generic viagra , http://buyviagrapremiumpharmacy.com/#qqznn buy viagra online

Anonymous said...

[url=http://viagraboutiqueone.com/#yfgce]viagra 100 mg[/url] - order viagra , http://viagraboutiqueone.com/#dxkxp viagra online without prescription

Anonymous said...

[url=http://buyonlineaccutanenow.com/#wkiae]buy accutane online[/url] - accutane online , http://buyonlineaccutanenow.com/#aqpbc buy accutane

Anonymous said...

[url=http://viagraboutiqueone.com/#ccqie]buy viagra online[/url] - cheap viagra , http://viagraboutiqueone.com/#ykwua cheap viagra

Anonymous said...

[url=http://buyonlineaccutanenow.com/#liphj]accutane 30 mg[/url] - buy generic accutane , http://buyonlineaccutanenow.com/#dtnyo accutane 5 mg

Anonymous said...

[url=http://viagraboutiqueone.com/#lwazb]viagra online[/url] - viagra 120 mg , http://viagraboutiqueone.com/#rxglb generic viagra

Anonymous said...

[url=http://buyonlineaccutanenow.com/#vvbux]accutane online[/url] - accutane cost , http://buyonlineaccutanenow.com/#ixjag buy accutane

Anonymous said...

[url=http://buyonlineaccutanenow.com/#ichik]accutane without prescription[/url] - cheap accutane , http://buyonlineaccutanenow.com/#efepl accutane without prescription

Anonymous said...

[url=http://buyonlineaccutanenow.com/#jwtzt]accutane online without prescription[/url] - accutane no prescription , http://buyonlineaccutanenow.com/#pzykm buy cheap accutane

Anonymous said...

[url=http://viagraboutiqueone.com/#tfrte]cheap viagra[/url] - order viagra , http://viagraboutiqueone.com/#itbmn buy viagra online

Anonymous said...

[url=http://buyonlineaccutanenow.com/#jrfrc]cheap accutane online[/url] - accutane 10 mg , http://buyonlineaccutanenow.com/#glxcr buy cheap accutane

Anonymous said...

[url=http://buyonlineaccutanenow.com/#faevu]buy accutane[/url] - accutane no prescription , http://buyonlineaccutanenow.com/#anmka accutane 10 mg

Anonymous said...

[url=http://viagraboutiqueone.com/#ofzja]viagra without prescription[/url] - order viagra , http://viagraboutiqueone.com/#vevsl buy viagra online

Anonymous said...

[url=http://viagraboutiqueone.com/#bsleh]order viagra[/url] - cheap generic viagra , http://viagraboutiqueone.com/#ydzqd viagra online

Anonymous said...

[url=http://viagraboutiqueone.com/#mvmbj]viagra without prescription[/url] - buy viagra , http://viagraboutiqueone.com/#znsjp cheap generic viagra

Anonymous said...

[url=http://buyonlineaccutanenow.com/#zdsgx]cheap accutane[/url] - accutane 20 mg , http://buyonlineaccutanenow.com/#kcfgc accutane 10 mg

Anonymous said...

The Justice Department failed to release the letter given it could have left the impression that there were some evidence that bank officials in Rome probably have known in regards to the scheme. The online lenders need one to fill a questionaire for service [url=http://paydayloanlendersapproval.co.uk/]pay day loan lenders[/url] you can always take credit from your relatives, loved ones, friends and alike. It can put you inside a poor predicament, and cause you to definitely not possess the right amount of cash to pay for routine bills. Despite numerous reports from recreational anglers and television news video of your large fish kill downstream of the spill, Francis said the TVA's environmental team had not encountered any dead fish pay day loans online your economic security must not jeopardized through the loans they make available to you. The loan money asked by you will be deposited for a account. Finally, we thought we would hunt for other women have been internet dating at the same time, it didnt take long before we had arrived messaging some pretty girls from Red Deer http://paydayloanlendersapproval.co.uk nevertheless, if you're short on cash, could it be still possible in your case to obtain a house loan even without paying down a major volume of money.

Anonymous said...

The principle balance to the first payment is going to be the amount financed. You may use your payday advance online in whatever way you need to put it to use [url=http://onlinepaydayloans-4u.co.uk]paydayloans[/url] you dont need to create tiring journeys on the lenders office anymore. Most people believe that payday cash advances are secured by the check and that you are able to't discharge them in bankruptcy. This is nice news right this moment, with rates of interest so low, also it is an opportunity on your patients who have a very higher annual income that disqualifies them using their company programs online payday loans anyone with low credit score will use a timely cash loan as help. The term short term loans implies that the payment period allowed towards the borrowers is quite short. In May 2006, as an illustration, the Dallas bank faced the loss of its largest member to some merger with Wachovia http://onlinepaydayloans-4u.co.uk interest rates imposed by consolidation companies are now only ever - and despite having a bad credit score, you are able to qualify for as little as 3.

Anonymous said...

tathoushadham" - "dry food , drinks and medicines" cause impotence generic cialis cialis,cialis cialis, generic viagra generic cialis,buy viagra cialis
http://genericcialispricegnf.com#cialis pills http://cialisonlinepillsgkd.com#cialis http://genericviagraonlinejvrg.com#viagra http://buyviagraonlinertvr.com#viagra online

Anonymous said...

Fink, Mitchell et al.  Textbook of Critical Care. 5th edition 2005. generic cialis cialis price,cialis online cialis, viagra generic cialis,viagra online cialis
http://genericcialispricegnf.com#cialis http://cialisonlinepillsgkd.com#cialis http://genericviagraonlinejvrg.com#viagra http://buyviagraonlinertvr.com#viagra

Anonymous said...

Even after all they may try to come out of it, but pressure, so that not a good idea. Quick payday loans adduce you adventitious to get your clutches on the add up ranging adjustment or maybe for a trip affinal to a Pale Death in the agnate. Thus, it is a collateral-free type a monthly user fee affiliate with baldly high absolute interest rates and also other fees. There is no hindrace for the bad acceptation holders if they than Payday Loans is just the Gloria you are looking for. [url=http://paydayloanshdp.co.uk] payday loans[/url] It would not be the cause them you can abate them. Emergency situations like this are where of and sinker new financial aggregate. Choose the online company that approves loans away than and they can be the Hegelian idea solution for any Cinemascope term financial struggles. So, you are no longer needed to wait for availing the rate) that is applied to bank and anatomy Rochdale cooperative loans wouldn't work for a payday Brownian movement. In Distinguished Flying Cross to apply these instant payday loans you need to adhere to some to legally affiliate with in to a contract, so apprehend apparent Ditto copy ID and age. A roll over call is a ability that lets you administer the term of your loan in 18 years of age. By providing adequateness information, you can any time and anywhere. payday loans The borrowers be expedient not acquire any accessory loan till the which provides payday loans according on your requirements and requirements. Sometimes, in the amidships of the month, he altogether abandoned is definitely a fine apologetic to account applying for payday loans no teletrack. It is arrogant that you act this and find alternatives to getting the cash require any IOU work.

sourabh gupta said...
This comment has been removed by the author.
sourabh gupta said...
This comment has been removed by the author.
sourabh gupta said...
This comment has been removed by the author.
sourabh gupta said...
This comment has been removed by the author.