/// <summary> /// 事务操作 /// </summary> public void TranstionDemo() { MultiAction actions = new MultiAction(); for (int i = 0; i < 10; i++) { if (i % 4 == 0) { DeleteAction delete = new DeleteAction(Entity); delete.Cast <cms_user>().Where(u => u.username == "wangjun"); actions.AddAction(delete); } if (i % 4 == 1) { UpdateAction update = new UpdateAction(Entity); update.Cast <cms_user>() .Where(u => u.username == "wangjun") .UnCast() .SqlKeyValue(cms_user.Columns.password, "1234567"); actions.AddAction(update); } } try { actions.Commit(); } catch (Exception) { actions.Rollback(); } }