Example #1
0
        /// <summary>
        /// 添加成语字典....
        /// </summary>
        public static void AddIdiomInfo()
        {
            var json = File.ReadAllText(@"G:\dick\download\uc\chinese-xinhua-master\data\idiom.json");

            var list = JsonConvert.DeserializeObject <DicModel[]>(json);

            list = list.Where(u => !string.IsNullOrWhiteSpace(u.word)).ToArray();

            UtilsContext utilsContext = new UtilsContext();

            int start = utilsContext.IdiomInfos.Count(), count = list.Length;

            while (start <= count)
            {
                utilsContext.IdiomInfos.AddRange(list.Skip(start).Take(1000).Select(u =>
                {
                    var spellArr = u.pinyin.Split(' ');
                    return(new IdiomInfo()
                    {
                        Derivation = u.derivation,
                        Example = u.example,
                        Explanation = u.explanation,
                        Spell = u.pinyin,
                        Word = u.word,
                        Abbreviation = u.abbreviation,
                        FirstSpell = spellArr[0],
                        LastSpell = spellArr[spellArr.Length - 1]
                    });
                }
                                                                                    ));
                utilsContext.SaveChanges();
                start += 1000;
                Console.WriteLine("添加成功!");
            }
        }
Example #2
0
 public IdiomsService(UtilsContext utilsContext) : base(utilsContext)
 {
 }
Example #3
0
 public BaseService(UtilsContext utilsContext)
 {
     UtilsContext = utilsContext;
 }