コード例 #1
0
        public void EnsureSeedData()
        {
            if (!_context.Chapters.Any() || !_context.Annotations.Any())
            {
                Chapter newChapter = new Chapter();
                newChapter.EntireChapterString = System.IO.File.ReadAllText("./../ch08.txt");

                _context.Chapters.Add(newChapter);

                string  json      = System.IO.File.ReadAllText("./../ch08.txt.json");
                JArray  jsonArray = JArray.Parse(json) as JArray;
                dynamic items     = jsonArray;
                foreach (dynamic item in items)
                {
                    Annotation annotation = item.ToObject <Annotation>();
                    _context.Annotations.Add(annotation);
                }
                _context.SaveChanges();
            }
        }
コード例 #2
0
 public bool SaveAll()
 {
     return(_context.SaveChanges() > 0);
 }