문제

We have moved our application away from using EntityFramework 4.2 and a couple of other commercial ORM products to ADO.NET for the performance reason, and It does prove the purpose.

but we have faced a problem that is the datatype timestamp.

in EF, we put a column with timestamp datatype in each of our table and we enable EF to use this column for versioning,

now, we are using ADO.Net with dataset/datatable, I'm not sure how to initialize a new value for timestamp column to each new row added to a datatable. here is one of the error. Column 'RECVERSION' is constrained to be unique. Value 'System.Byte[]' is already present. we could disable the constrain, but we would like to have this constrain for row version Question: How do we have some kind of automatic initialize a new value for the timestamp in a disconnected dataset/data table environment? Thanks

도움이 되었습니까?

해결책

The column of type TIMESTAMP (or ROWVERSION as of SQL Server 2008) will always be handled automatically by SQL Server.

And cannot and must not insert any values into it. Just leave it alone! You should just select it to detect when a row has been changed between the time you read it, and the moment you're trying to update it.

Do not attempt to insert or set this value! Just exclude it from any of your SQL INSERT or UPDATE statements. SQL Server does all the work for you.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top