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

ORM mapping of timestamp

12 Answers 210 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Andreas Kaech
Top achievements
Rank 1
Andreas Kaech asked on 15 Nov 2008, 05:10 PM
Hi Telerik,
I have problems with the timestamp type when reverse mapping.
How to map this type?

Best regards,
Andreas

12 Answers, 1 is accepted

Sort by
0
Accepted
Thomas
Telerik team
answered on 18 Nov 2008, 03:21 PM
Hi Andreas,

if you are referring to T-SQL timestamp columns: this can be done with the following, yet undocumented extension in the app.config file (which you need to enter manually, the design UI has not been implemented yet):

<class name="....">
            <extension key="db-optimistic-locking" value="backend">
              <extension key="db-column">
                <extension key="db-type" value="BIGINT" />
                <extension key="db-column-name" value="vers" />
                <extension key="db-length" value="8" />
              </extension>
            </extension>
</class>

In this case, vers is the name of the version column holding the timestamp value.
Please note, that this is not an official feature yet.

Kind regards,
Thomas
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mike
Top achievements
Rank 1
answered on 13 Feb 2009, 12:03 AM
Thomas, how is this done practically?  I've started with   build 2008.03.1327.2 trialling with two tables ( where my project has over 40 ) - I did this change manually and reran the Reverse Engineer.  I got a property setter for the Timestamp field?  
Michael
0
Thomas
Telerik team
answered on 13 Feb 2009, 11:43 AM
Hi Mike,

again: Not an official feature yet, as we dont have a GUI for controlling this setting.

OpenAccess knows about the version column. That column can be mapped to a field or not. When data is read for the first time in a transaction boundary (or written to), OpenAccess makes sure it has the value of that column. When you store your changes in Transaction.Commit, the value of this column is used and appended in the UPDATE ... WHERE clause. Where the value for the column is held during the course of the transaction? In an internal 'State' instance, so it does not matter whether the value is visible in a field or not.

Hope this clarifies it a bit,
Thomas
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Thomas
Top achievements
Rank 1
answered on 24 Feb 2009, 08:29 AM
Hi Telerik,

I also have this problem with MS SQL Server timestamp fields. I am porting an application where we used this field for concurrency control, but now with OA I get the error that I am not allowed to write into this field.
I have changed the app.config according to this post but it still will not work. Should I exclude the timestamp field from the mapping?

Regards,
Thomas
0
Thomas
Telerik team
answered on 24 Feb 2009, 09:14 AM
Hello Thomas,

why are you writing to the field? The field's value is obtained from the server, and passed back uninterpreted/unaltered to the server as part of the UPDATE statement generated during Transaction.Commit(). Currently it is best to not make the column user visible, and the mapping snippet given in a previous post is working fine.

Please note that we had a rare issue with timestamp columns in the past release, but 2008.03.1421.01 does not have the problem.

Kind regards,
Thomas
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Thomas
Top achievements
Rank 1
answered on 24 Feb 2009, 12:05 PM
Hello Thomas.

The error appears when I create a new object like so:
User u = new User();
objectscope.Transaction.Begin();
objectscope.Add(u);
objectscope.Transaction.Commit();

I have tried several ways but none worked properly. I tried setting the timestamp with null or with an empty byte array (which it seems to be). In another project I removed the timestamp fields from the classes.

Regards
Thomas
0
Thomas
Telerik team
answered on 26 Feb 2009, 12:27 PM
Hello Thomas,

this is strange as on my side this works exactly as I described. Please verify that such a fragment of the app.config as given ealier in this thread is used for the User class.
Is the timestamp column in the database nullable?

Regards,
Thomas
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Thomas
Top achievements
Rank 1
answered on 27 Feb 2009, 11:03 AM
Hello Thomas.

It gets even more confusing. I just reran the Reverse Mapping Tool and after are merge with the database the all the unsupported timestamp fields get recognized as OpenAccess versioning fields. Yet I did not find anything about this in the documentation.

I know that the old Vanatec version could use a datetime column (which was called timestamp in the docs) for versioning, but was not able to make something about the SQL Server timestamp column (which really is a timestamp).

What can I do now? Should I use the MS SQL Server timestamp column for versioning and concurrency control or should I replace this column with an int column?

Regards,
Thomas
0
Dimitar Kapitanov
Telerik team
answered on 27 Feb 2009, 12:19 PM
Hello Thomas,
Just to update you we are still investigating the reason behind the error. When we have an understanding what is happening exactly and a solution for you, we will notify you asap.

All the best,
Dimitar Kapitanov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Thomas
Telerik team
answered on 27 Feb 2009, 09:15 PM
Hello Thomas,

yes, as I said : this is still an unofficial feature, where the columns are correctly detected by the reverse engineering, but you are not able yet to use the forward wizard to enter the same mapping; the runtime part is also fine, meaning that with the correct mapping (as produced by the rev-eng.) you are able to use such TIMESTAMP columns for concurrency control.
 I will ask product management to increase the priority of this feature.

Regards,
Thomas
0
Mike
Top achievements
Rank 1
answered on 13 Mar 2009, 04:08 PM
Thomas,
Any news from product management on this one?  My efforts at using class inheritance turned into a nightmare of multiple version columns.  Check out this support ticket http://www.telerik.com/account/support-tickets/view-ticket.aspx?threadid=193103  .
If the Product Manager is not accommodating please ask him/her to de-prioritise his teams activity improving LINQ and instead develop a solution for Row Versioning Concurrency Control in SQL-Server which results in the Reverse Engineer generating code the Forward Mapper understands. 
Michael
 
0
Jan Blessenohl
Telerik team
answered on 18 Mar 2009, 09:26 PM
Hi Mike,
We will definitly work on the wiazrd enhancement enhancement for the next release. Rowversion support in the reverse mapping wizard is already on the list. I hope that we can do it for one of the patches.

Regards,
Jan Blessenohl
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
General Discussions
Asked by
Andreas Kaech
Top achievements
Rank 1
Answers by
Thomas
Telerik team
Mike
Top achievements
Rank 1
Thomas
Top achievements
Rank 1
Dimitar Kapitanov
Telerik team
Jan Blessenohl
Telerik team
Share this question
or