Page 1 of 1

Concurrency

Posted: Tue 23 Jun 2015 22:48
by damon.cognito
Our database is a large multi-user thing so we basically want to set Currency to fixed on every field. Is there a way to do this when creating the model other than writing a script to go through the model and making changes?

Secondly, the currency is at the record level, is there any support for it at the field level? For example, take

Table1 (id, field1, field2, field3)
(1, 1, 1, 1)
(2, 2, 2, 2)

If we load the first record (1, 1, 1) and only change field2 to 2 I want the sql to be produced to be:

Code: Select all

update Table1 set field2 = 2 where id = 1 and field2 = 1
not

Code: Select all

update Table1 set field2 = 2 where id = 1 and field1 = 1 and field2 = 1 and field3 = 1
i.e. it is valid for other fields to have been changed, just not the ones I have changed.

Re: Concurrency

Posted: Wed 24 Jun 2015 14:41
by Shalex
damon.cognito wrote:Our database is a large multi-user thing so we basically want to set Currency to fixed on every field. Is there a way to do this when creating the model other than writing a script to go through the model and making changes?
You are working with the Entity Framework model via Entity Developer, aren't you? Please select all necessary class properties in Model Explorer and set "Concurrency Mode=Fixed" for all of them at once.
damon.cognito wrote:Secondly, the currency is at the record level, is there any support for it at the field level? For example, take

Table1 (id, field1, field2, field3)
(1, 1, 1, 1)
(2, 2, 2, 2)

If we load the first record (1, 1, 1) and only change field2 to 2 I want the sql to be produced to be:

Code: Select all

update Table1 set field2 = 2 where id = 1 and field2 = 1
not

Code: Select all

update Table1 set field2 = 2 where id = 1 and field1 = 1 and field2 = 1 and field3 = 1
i.e. it is valid for other fields to have been changed, just not the ones I have changed.
The expression tree for the WHERE clause is constructed in EF engine, then it is passed to our EF provider for generating database specific SQL. Please address this suggestion (expression tree optimization) to Microsoft EF developers.

JIC
There is another approach to implement concurrency processing. Create a timestamp column in your table and refresh its value each time the record is updated. The timestamp column can be refreshed in two alternative ways
* at database side via trigger: http://postgresql.nabble.com/Re-timesta ... 46935.html
* at EF code side: iterate through all tracked changes and update the timestamp properties of all changed records in all entities in the SavingChanges event handler

Re: Concurrency

Posted: Wed 24 Jun 2015 17:36
by damon.cognito
Shalex wrote:You are working with the Entity Framework model via Entity Developer, aren't you? Please select all necessary class properties in Model Explorer and set "Concurrency Mode=Fixed" for all of them at once.
Yes I am, but I just need to check what you are suggesting... are you suggesting expanding each of the 300+ class nodes, then selecting each individual field in each node?
Shalex wrote:
damon.cognito wrote:Secondly, the currency is at the record level, is there any support for it at the field level? ...
The expression tree for the WHERE clause is constructed in EF engine, then it is passed to our EF provider for generating database specific SQL. Please address this suggestion (expression tree optimization) to Microsoft EF developers.

JICx
There is another approach to implement concurrency processing. Create a timestamp column in your table and refresh its value each time the record is updated.
Thanks for the suggestion but that row level again, not field level; if I'm just updating field2 I don't care if field1 has changed (and visa versa). But if that is controlled by MS then I guess there is not much hope!

Re: Concurrency

Posted: Thu 25 Jun 2015 12:51
by Shalex
damon.cognito wrote:want to set Currency to fixed on every field. Is there a way to do this when creating the model [...]?
There is no way at the moment. Please submit your suggestion at http://devart.uservoice.com/forums/3867 ... -developer.
damon.cognito wrote:are you suggesting expanding each of the 300+ class nodes, then selecting each individual field in each node?
Open the *.edml model, navigate to Tools > Entity Developer > Model Explorer, press Ctrl+F to open the Find window:
Find what: .*
Look in: Properties
Use regular expressions: Checked
Now press Select All which will mark all properties.

Re: Concurrency

Posted: Thu 25 Jun 2015 13:39
by damon.cognito
I tried your suggestion which is quite neat except it took over 10 minutes to 'select all' and another couple of minutes once I changed the setting (and this is not a slow machine). So I'll stick to an external script for now and post the suggestion at the link you provided. Thanks for your help.

cheers!

Re: Concurrency

Posted: Fri 26 Jun 2015 12:05
by Shalex
damon.cognito wrote:I tried your suggestion which is quite neat except it took over 10 minutes to 'select all' and another couple of minutes once I changed the setting (and this is not a slow machine).
We will investigate the issue and notify you about the result.

Re: Concurrency

Posted: Thu 16 Jul 2015 14:26
by Shalex
damon.cognito wrote:I tried your suggestion which is quite neat except it took over 10 minutes to 'select all' and another couple of minutes once I changed the setting (and this is not a slow machine).
The bug with freezing Visual Studio when using the Find dialog in large models is fixed in the new (5.7.654) build of Entity Developer: http://forums.devart.com/viewtopic.php?f=32&t=32134.