Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 29th, 2011, 03:57 PM
Registered User
 
Join Date: Mar 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to populate UI without breaking n-tier paradigm

Greetings,

I am modeling my app based on your methodology where we have the 3 layers.

Say that I have a Visit table, a dal visit, a bo visit, and a bll visit class.

My table looks like:

Visit (visitid, visitdate, visittime, visitStatusCode, visitCategoryCode, etc)

My bo.Visit has the same properties as the visit table above.

The dilemma is this: on the ui, i need to display a grid showing all the visits but, instead of showing the internal codes for visits status and visit category. I want to display the descriptions: visit status description and category description.

In the past, i added cached datasets and an item template using a function to translate the code to the description on the row bound event.

This seems expensive and also breaks all the n-tier philosophy.

I could also create a FAT object with all the properties I would consume on the UI by getting all the properties in the dal into my business object. My concern is that for each visit that I load, I will have to make 2 more calls to get the visit status and category descriptions.

Or, use a view or proc with all the properties i need and on the dal.getAll() populate the FAT object?

Please advise,
huambo

happy new year
 
Old December 30th, 2011, 06:53 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

As suggested earlier, you could create a Category object (or some other NameValue object) and add it as a property on the Visit class.

Then when you instantiate the Visit instance, you also instantiate a new Category. How you do that is up to you. You could forward it the SqlDataReader so the Category is responsible for the data access, or you could retrieve the two values from the reader in the Visit class and then pass them to the Category's constructor.

Alternatively, you could take a look at the Entity Framework, with the Code First option in particular, as EF takes care of all of this for you.

Cheers.

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old December 30th, 2011, 08:33 AM
Registered User
 
Join Date: Mar 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar,

Thanks for the suggestion! This would work for lists of value pairs like categories, statuses, etc.

I wonder if, for example, you also need to get the patient's last and first names?
That is, for each visit object that you load from the database, you make another call to the patient table to get the patient info.

The real question is: is it 'cheaper' to build the result set on the server by joining the visit, patient, visit status, visit category tables and then just consume that?

My problem with this last option is that it defeats the purpose of building a layered architecture?

Thanks,
Happy Year!
Huambo
 
Old December 30th, 2011, 08:45 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
My problem with this last option is that it defeats the purpose of building a layered architecture?
Yes, it's cheaper as you only need to make one call.

Not sure if it breaks the design. Your Visit class can be considered in charge of its sub data.... A stored proc would be able to query all Visit related data.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between 3 tier and N-Tier architecture Manoj Bisht ASP.NET 2.0 Professional 2 May 9th, 2008 08:42 AM
Breaking out of frames takabyte PHP How-To 0 August 6th, 2007 11:31 AM
Breaking a String Macsood Intro Programming 1 January 23rd, 2006 01:09 PM
Breaking a String Macsood General .NET 1 November 17th, 2005 11:29 PM
OOP:FormCreation\Validation -Paradigm shift needed webnerd PHP How-To 2 May 9th, 2005 10:03 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.