Suppose I was writing an application where users had to book appointments (in my case, a user is paired with an employee and that employee will do work for that user at a particular time of day). How would I ensure that 2 users did not end up booking the same appointment using NHibernate or Entity Framework? Would I open a transaction and do something like:
BeginTransaction();
if(!AppointmentBooked(userId, employeeId, time)) // read
BookAppointment(userId, employeeId, time); // write
CommitTransaction();