My development team has run into a design issue. I'm hoping someone can help me clean this part of the architecture up a bit.
In my system, I have an enum with 250 members [one member represents a distinct drop down]. In order to populate the drop downs on any given window, that form sends in the enum members that relate to the drop downs needed, and the drop down information is returned.
In other words, say for example, we have 3 windows. Window A has drop downs X, Y and Z. Window B has drop downs W, X and Y and Window C has drop downs T, U and W. My DropDownType enum would consist of T, U, W, X, Y, Y, and Z. So for a specified window, given the drop downs on that window, I query for the data to appear in those drop downs.
This is a simplified example because my application consists of > 250 distinct drop downs.
As you can imagine, I have a factory setup to return the data for each drop down. And this factory is called for each drop down requested.
switch (dropDownType)
{
case DropDownType.T:
return (from t in dataContext.GetTable<TableOne>()
select new DropDownDto
{
DropDownDisplayName = t.ColumnA,
DropDownValue = t.ColumnB
}).ToList();
case DropDownType.U:
return (from u in dataContext.GetTable<TableTwo>()
select new DropDownDto
{
DropDownDisplayName = u.ColumnC,
DropDownValue = u.ColumnD
}).ToList();
// etc...
}
Since I have so many members in this enum, does anyone know of a more elegant way of coding this? Do you think transforming this into factory methods would be helpful (but then we'd have to worry about 250 separate files in our source...)? Is there another pattern out there that is more useful? Just having this HUGE switch statement is getting unmanageable.
Any help is greatly appreciated. Thanks in advance!