在这里,我有一个方法将返回匹配的参数,只返回字符串作为返回类型,并且它工作正常......
private static string GetSortedParameter(string modelValue)
{
string returnValue = null;
if (modelValue == "UserId")
{
returnValue = "UsrID";
}
if (modelValue == "Status")
{
returnValue = "TransactionStatusTypeName";
}
if (modelValue == "ProjectCaseNumber")
{
returnValue = "PROJCASE";
}
if (modelValue == "CP")
{
returnValue = "CPNumber";
}
if (modelValue == "ItemID")
{
returnValue = "ItemID";
}
if (modelValue == "TypeOfChange")
{
returnValue = "TransactionTypeName";
}
if (modelValue == "ChangeDescription")
{
returnValue = "TransactionTypeDescription";
}
if (modelValue == "CreatedOnEnd")
{
returnValue = "CreatedDateTime";
}
if (modelValue == "UpdatedOnEnd")
{
returnValue = "UpdatedDateTime";
}
if (modelValue == "Comment")
{
returnValue = "Comments";
}
return returnValue;
}
在这里我调用这个方法
if (request.Sorts != null && request.Sorts.Count > 0)
{
sortField = request.Sorts[0].Member;
sortDirection = request.Sorts[0].SortDirection.ToString();
}
string SortFieldParameter = GetSortedParameter(sortField);
但是我想将枚举用于这种类型,我该如何将枚举用于这种类型的匹配参数,它将一个值作为输入参数并给出匹配的值.....
你能给出任何想法和解决方案吗....
我也在寻找任何通用的解决方案......