private bool SaveDiary() { Current.RowVersion = DateTime.Now; if (Current.ID > 0) { return(DapperExHelper <Diary> .Update(Current)); } else { return(DapperExHelper <Diary> .Insert(Current) > 0); } }
private void DeleteButton_Click(object sender, RoutedEventArgs e) { Diary selectedRow = (Diary)_lvwDiarys.SelectedItem; string title = selectedRow.Title; string message = $"确认要删除该日记 “{title}” 吗?"; if (MessageBox.Show(message, "删除日记", MessageBoxButton.YesNoCancel, MessageBoxImage.Exclamation) == MessageBoxResult.Yes) { //selectedRow.IsDeleted = true; //DapperExHelper<Diary>.Update(selectedRow); if (DapperExHelper <Diary> .Delete(selectedRow)) { LoadDiarys(new DateTime(_year, _month, _day)); } else { MessageBox.Show("删除日记失败!"); } } }
public IList <Diary> GetDiaries(string sql) { return(DapperExHelper <Diary> .Query(sql).ToList()); }
public Diary GetDiary(int id) { return(DapperExHelper <Diary> .Get(id)); }
public IList <Diary> GetDiaries() { return(DapperExHelper <Diary> .GetAll().ToList()); }