创建字典进行字段匹配

 

--查询

var postNumFiled = Static_Dic.RoleType_PostNum.FirstOrDefault(o => o.Key == roleType).Value;

 

--封装匹配的字典

public static Dictionary<int, string> RoleType_PostNum
{
get
{
Dictionary<int, string> dic = new Dictionary<int, string> { };
dic.Add(RoleType.MR.GetHashCode(), "PostNum");
dic.Add(RoleType.DM.GetHashCode(), "PostNum1");
dic.Add(RoleType.RM.GetHashCode(), "PostNum2");
dic.Add(RoleType.AD.GetHashCode(), "PostNum3");
dic.Add(RoleType.BUD.GetHashCode(), "PostNum4");
dic.Add(RoleType.CEO.GetHashCode(), "PostNum5");
return dic;
}
}

posted @ 2023-06-01 16:37  小易儿  阅读(53)  评论(0)    收藏  举报