Answered by:
Dropdownlist values and Layers in Application

Question
-
User1733326705 posted
Here is the scenario.
Every project has a Supervisor.
When I select the supervisor for a particular project, I'm using a dropdownlist.Table is like this
ProjectId | SupervisorId | ......
--------------------------------------1 | 1
In my application, I'm binding a Collection of Supervisor type, which I'm feeling that it is an additional overhead. Becuase I only want his ID. So binding an object collection to the dropdown which seems no worth.
Am I correct..? or are there any other better way to do this..?
Saturday, March 13, 2010 11:31 AM
Answers
-
User-525215917 posted
If you business layer gives you supervisors list then you should use it. I don't know how your DAL works and therefore I really cannot say if there is some overhead or not. If your business layer is able to ask Id-Title pairs for objects from DAL then you can use this functionality. If it doesn't then you should be happy with list of supervisors.
To get supervisor objects or to get objects with their ID-s requires basically the same code. The difference is only in object type and in the cound of properties you have to assign. If you have a l ot of supervisors then this may be the issue but in this case you don't use dropdown anymore because it is hard to use with many options in it.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, March 13, 2010 1:24 PM -
User-525215917 posted
You can cache objects created for current request (first level cache) or for all requests (second level cache) so you don't have to worry about performance right now. In the real world you start optimizing so narrow things after you have implemented at least first level cache. As it comes to this point you should this way or other solve the much wider problem - how to decrease the load of database.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, March 14, 2010 2:41 PM
All replies
-
User-525215917 posted
If you business layer gives you supervisors list then you should use it. I don't know how your DAL works and therefore I really cannot say if there is some overhead or not. If your business layer is able to ask Id-Title pairs for objects from DAL then you can use this functionality. If it doesn't then you should be happy with list of supervisors.
To get supervisor objects or to get objects with their ID-s requires basically the same code. The difference is only in object type and in the cound of properties you have to assign. If you have a l ot of supervisors then this may be the issue but in this case you don't use dropdown anymore because it is hard to use with many options in it.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, March 13, 2010 1:24 PM -
User1733326705 posted
Thanks for replying.
I can customize the DAL as I want.
What is the best method to do this..? Use a Hashtable ????
Saturday, March 13, 2010 11:18 PM -
User-525215917 posted
I think the best idea is to create Supervisor objects and use them. Don't start trashing your DAL and making something very smart there if it is not provided by DAL (one point from my little survival guide :)). To get better idea about your toolset I want to ask do you use some O/R-mapper (NHibernate, Entity Framework) for DAL or do you have manually written DAL?
Sunday, March 14, 2010 4:21 AM -
User1733326705 posted
No I have a custom DAL.
One of issue in my mind is, what is the use of load all the properties of Supervisor objects. I mean, I surely know I only use two properties, SupervisorID (get the value) and Name (to display). To me, it seems a wastage. Even I would like to use some dictionary type read-only collection.
I want to know the best way to handle this.
Sunday, March 14, 2010 1:20 PM -
User-525215917 posted
You can cache objects created for current request (first level cache) or for all requests (second level cache) so you don't have to worry about performance right now. In the real world you start optimizing so narrow things after you have implemented at least first level cache. As it comes to this point you should this way or other solve the much wider problem - how to decrease the load of database.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, March 14, 2010 2:41 PM