views:

54

answers:

1

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();
+1  A: 

Check this article out it might be helpful. I had a problem like yours. Entity Framework has the ability of doing non-optimistic concurrency via configuration.

http://msdn.microsoft.com/en-us/library/bb738618.aspx

JeremySpouken