web + concurrency

Posts   
 
    
quentinjs avatar
quentinjs
User
Posts: 110
Joined: 09-Oct-2009
# Posted on: 29-Oct-2009 23:38:14   

I realized today that part of my headache could be self induced....

Assumptions 1. Project is ASP.NET 2. Require Concurrency to be handled - suggested to use a TimeStamp. 3. On Edit post, * the application receives the data * loads the specific record (from database) * applies the changes * I do a save, that triggers the concurrency.

Questions 1. Since its stateless the and application needs to know the timestamp of the record at time it was edited, is the best approach to pass the timestamp value to the webpage (as a hidden field). And then on return have it update this field in the entity?

  1. If #1 is true then is there a special way that timestamp fields need to be passed to the web page and then retrieved? (Since its a Byte[] this is not your normal field.)
quentinjs avatar
quentinjs
User
Posts: 110
Joined: 09-Oct-2009
# Posted on: 30-Oct-2009 05:30:32   

The plot thickens... the entity field for TimeStamp is read only. so concurrency is getting more complicated.

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 30-Oct-2009 10:30:57   

So instead of having the timestamp stored in the page, you should save the entity itself to the page. That's when Databinding kicks. Try using LBLGenProDaaSource with a FormView for example.

quentinjs avatar
quentinjs
User
Posts: 110
Joined: 09-Oct-2009
# Posted on: 30-Oct-2009 16:06:54   

I'm not using WebForms, so a FormView I'm not sure would work. Is there another way to store the entire entity to the View, as that would be perfect for many reasons.

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 02-Nov-2009 10:42:23   
  1. If #1 is true then is there a special way that timestamp fields need to be passed to the web page and then retrieved? (Since its a Byte[] this is not your normal field.)

I'm not using WebForms

I don't understand you are asking about how to pass a field to a web page, yet you say you don't use WebForms, how is this possible in ASP.NET ?

quentinjs avatar
quentinjs
User
Posts: 110
Joined: 09-Oct-2009
# Posted on: 02-Nov-2009 18:00:41   

There is 2 ways to build web systems in studio (at least supported by MS). The well known one is WebForms, the other way is via views in the MVC solution. In this approach the Views are template generated and then editable as asp pages.

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 03-Nov-2009 11:14:15   

Is there another way to store the entire entity to the View, as that would be perfect for many reasons.

I'm not an expert when it comes to MVC, but as far as I remember you can store it in TempData or ViewData.

quentinjs avatar
quentinjs
User
Posts: 110
Joined: 09-Oct-2009
# Posted on: 03-Nov-2009 17:04:33   

Ah, okay. I will look into that.

I know that there is a ViewData, and stuff can be stored there, but I've not played with it a lot. I will once my other problem is resolved so it compiles.. And I'll pass my feedback here for others to learn from.