This is a migrated thread and some comments may be shown as answers.

How to update based only on the PK...or how to improve continuous updates

1 Answer 64 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Roger
Top achievements
Rank 1
Roger asked on 01 Apr 2011, 08:12 AM
I am using VS 2010, Telerik WPF controls (WPF using the MVVM pattern), WCF (TCP/binary) and OpenAccess.

I have a scenario where I need to perform continuous updates, sometimes to the same piece of data. For example, I have a RadNumericUpDown control that is bound to a model-view, where every change to the value will result in an update. This works reasonably well but sometimes I get an error that indicates that the update might be using cached data.

If I'm trying to update column C in Table T, with column A being the PK (Identity), the OA-generated SQL follows this sort of format:

UPDATE T SET B=?, C=? WHERE A=? AND C=?

The WCF calls are ordered, so I know that they are being executed in the correct sequence. I'm using the OA Domain Model, where I query the table by PK and then make my changes before committing. The error I receive suggests that the value assigned to C in the "AND C=?" clause is actually the value that existed before the previous call, so of course the row is not found.

  1. Why is the "AND C=?" clause in the generated query when all I care about is updating for A? If not for that clause, this call would always work.
  2. Is there a way to make these calls that would be more efficient?
  3. Is there an alternative to my approach that would accomplish the same thing?

1 Answer, 1 is accepted

Sort by
0
Petko_I
Telerik team
answered on 06 Apr 2011, 05:29 PM
Hello Roger,

The comparison you see in the WHERE clause of the SQL statement is done because the concurrency control strategy you have for the persistent type mapped to table T is different from "version", "backend" or "timestamp".  The concurrency control strategy determines exactly what properties are compared for conflicts during updates and the default one is "changed". There are a few articles in our documentation that although scattered shed some light on the topic with the concurrency modes. You can find information about the "none", "version", "changed" and "timestamp" concurrency modes on this page. Additional information regarding the "backend" mode can be found here. The topics are still under the classic wizards sections, however, we are in a process of updating our documentation and you can expect to see numerous improvements in the near future.

The "version" concurrency strategy enables you to select a single property that will be used to resolve conflicts during updates and will remove the need for comparison of multiple columns in the database. The version field should be int or long and its value is automatically calculated by OpenAccess on inserts and updates. To view or change the concurrency control mode you can select a persistent type in the designer, press F4 and look at the Concurrency Mode facet.

If you have further questions, do not hesitate to contact us back.

Regards,
Petko_I
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Development (API, general questions)
Asked by
Roger
Top achievements
Rank 1
Answers by
Petko_I
Telerik team
Share this question
or