public static bool IsExistCBSCode(string code) { bool flag = false; using (pm2Entities entities = new pm2Entities()) { if ((from m in entities.Res_ResourceType where m.CBSCode == code select m).ToList <Res_ResourceType>().Count > 0) { flag = true; } if (!flag) { ContractType type = new ContractType(); if (type.GetListByCBSCode(code).Count > 0) { flag = true; } } } return(flag); }