In my code, i have switch case such as
switch(iSortCol) {
case1: if(iSortDir="desc"){order1 = order1.OrderByDescending(x=>x.GROUPNAME);
elseif(iSortDir="asc")order1 = order1.OrderBy (x=>x.GROUPNAME);
case2: if(iSortDir="desc"){order1 = order1.OrderByDescending(x=>x.GROUPMASTERID);
elseif(iSortDir="asc")order1 = order1.OrderBy (x=>x.GROUPMASTERID);}
....
case80:
case81:
}
The growing of "switch...case..." leads more maintain work for the code, i am thinking how to covert the code to Dictionary or strategy pattern for a better maintainability.
By the way, the property in order 1 such as "GROUPNAME"
,"GROUPMASTERID"
has different type
E.g. the "GROUPNAME"
in (x=>x.GROUPNAME)
is string type, but the "GROUPMASTERID"
in (x=>x.GROUPMASTERID)
int type.
Could anyone give me some clues, really appreciated