/// <summary> /// 事务保存实体 /// add by lpl /// 2019-1-2 /// </summary> /// <param name="entity"></param> /// <param name="listentity"></param> /// <returns></returns> public bool SaveGongGao(GongGaoMangerEntity entity, List <GongGaoDetialEntity> listentity) { //事务开始 WriteDatabase.BeginTransaction(); try { //公告管理表插入 PersistNewItem(entity); //发送公告到个人表 foreach (var liEntity in listentity) { new GongGaoDetialDal().PersistNewItem(liEntity); } } catch (Exception e) { //事务回滚 WriteDatabase.AbortTransaction(); throw e; } //事务提交 WriteDatabase.CompleteTransaction(); return(true); }
/// <summary> /// 结束事务 /// </summary> public void AbortTransaction() { WriteDatabase.AbortTransaction(); }