public int GetTotalNotesNum() { using (var dc = new MyDataContext()) { return(!dc.DatabaseExists() ? 0 : Enumerable.Sum(dc.NotebookTable, notebook => notebook.NotesNum)); } }
public static void CreatetDatabaseIfNeeded() { using (var dc = new MyDataContext()) { if (dc.DatabaseExists()) return; dc.CreateDatabase(); Debug.WriteLine(DateTime.Now.ToLongTimeString() + " 数据库创建完成。"); } }
public int GetTotalNotesNum() { using (var dc = new MyDataContext()) { return !dc.DatabaseExists() ? 0 : Enumerable.Sum(dc.NotebookTable, notebook => notebook.NotesNum); } }
public List <NotebookEntity> GetAllNotebook() { using (var dc = new MyDataContext()) { return(!dc.DatabaseExists() ? new List <NotebookEntity>() : dc.NotebookTable.ToList()); } }
public List<NotebookEntity> GetAllNotebook() { using (var dc = new MyDataContext()) { return !dc.DatabaseExists() ? new List<NotebookEntity>() : dc.NotebookTable.ToList(); } }
public static void DeleteDatabaseIfExists() { using (var dc = new MyDataContext()) { if (dc.DatabaseExists()) { dc.DeleteDatabase(); } Debug.WriteLine(DateTime.Now.ToLongTimeString() + " 数据库已被删除。"); } }
public static void CreatetDatabaseIfNeeded() { using (var dc = new MyDataContext()) { if (dc.DatabaseExists()) { return; } dc.CreateDatabase(); Debug.WriteLine(DateTime.Now.ToLongTimeString() + " 数据库创建完成。"); } }
/// <summary> /// 删除悬空图片(没有笔记引用的图片)。 /// </summary> public static void DeleteNoRootImages() { using (var dc = new MyDataContext()) { if (!dc.DatabaseExists()) return; foreach (var img in dc.ImageTable) { if (NoteDao.Inst.NoteExist((img.BelongedNotePath))) continue; DeleteIfExist(img.Id); Debug.WriteLine("删除本地悬空图片:" + img.ImgLocalSavePath); } } }
/// <summary> /// 删除悬空图片(没有笔记引用的图片)。 /// </summary> public static void DeleteNoRootImages() { using (var dc = new MyDataContext()) { if (!dc.DatabaseExists()) { return; } foreach (var img in dc.ImageTable) { if (NoteDao.Inst.NoteExist((img.BelongedNotePath))) { continue; } DeleteIfExist(img.Id); Debug.WriteLine("删除本地悬空图片:" + img.ImgLocalSavePath); } } }