62,244
社区成员




private static Dictionary<string, string> classifyDic;
public static string GetClassifyByCode(string code)
{
string retVal;
FillCache(Constants.COMMON_TYPE_CLASSIFY, code, classifyDic);
classifyDic.TryGetValue(code, out retVal);
return retVal;
}
private static void FillCache(string type, string code, Dictionary<string, string> dic)
{
MongoDBContext<CommonCode> dbContext = new MongoDBContext<CommonCode>();
List<CommonCode> codeList = dbContext.List(model => model.CodeType == type && model.Code == code);
dic = codeList.ToDictionary(model => model.Code, model => model.CodeName1);
}
private static Dictionary<string, string> classifyDic;
public static string GetClassifyByCode(string code)
{
string retVal;
classifyDic = FillCache(Constants.COMMON_TYPE_CLASSIFY, code);
classifyDic.TryGetValue(code, out retVal);
return retVal;
}
private static Dictionary<string, string> FillCache(string type, string code)
{
MongoDBContext<CommonCode> dbContext = new MongoDBContext<CommonCode>();
List<CommonCode> codeList = dbContext.List(model => model.CodeType == type && model.Code == code);
return codeList.ToDictionary(model => model.Code, model => model.CodeName1);
}