I have been working on an MVC application for the past few days. In this I use a couple of dropdownlists and wanted what I did to be good practice. I have about 5-6 drop-down menus that are pulled from the database. There drop-down lists have an identifier and description field. I can get dropdown menus with the problem. However, when I list the main table, there is a performance issue.
All drop-down lists are saved as integers in the database, so I have a field just like in BaseModel (a class that maps to HBM). When I list all the records from the database, I predict that I get an integer in the record. So far I have no performance issues.
I wanted to display a description for the selected item in order to create a model class for the drop-down lists and have a method in the model that will talk to the database and get a description based on the selection. The problem is that it slows down the page loading. I wanted to know if I need to make a design change so that it loads faster. Below is the code that I have
MasterList1 table (state and county are integers in this table) State Dropdown (main table with all states with identifier) ββDrop-down list window (main table with all counties with identifier)
BaseModel Classes for Nhibernate
MasterList1 State County
Model class
MasterList1Model StateModel CountyModel
Storage Class MasterList1Repo StateRepo CountyRepo
View MasterList1
In the view, I call a string property in the BaseModel class. In the property, I make a call to the Model class, which in turn sends a Repo call to get the string. Here is the method in the Repo class.
public ApplicationTypeMaster GetByID(int ID) { using (ISession session = NHibernateHelper.OpenSession()) { return session.Get<ApplicationTypeMaster>(ID); } } public string GetApplicationTypeByID(int ID) { return GetByID(ID).ApplicationTypeDescription.ToString(); }
I am not sure how to improve this. Any suggestions?
source share