Ejemplo n.º 1
0
        /// <summary>
        /// 根据查询字典数据中的相应的数据
        /// </summary>
        /// <returns>字典数据类型</returns>
        public IDictionary <string, CodeType> GetAllCode()
        {
            var result = new Dictionary <string, CodeType>();
            var codes  = codeManagerRepository.LoadEntities(p => p.LogicDeleteFlag == false)
                         .OrderBy(p => p.ParentId).OrderBy(p => p.ShowIndex).ToList();

            // 创建CodeType集合
            foreach (var code in codes.Where(p => p.ParentId == 0).ToList())
            {
                var codeType = new CodeType(code.Code, code.Text, code.ShortText);

                // CodeType集合内添加字典数据
                codeType.AddRange(codes.Where(p => p.ParentId == code.Id).Select(p => new CodeInfo(p.Code, p.Text, p.ShortText)).ToList());

                result.Add(code.Code, codeType);
            }

            return(result);
        }