views:

38

answers:

1

We're trying to update an entity via WCF, and the entity contains a Timestamp column. When we attempt the update, we get the following Data.Linq error, "A member that is computed or generated by the database cannot be changed." This message is referring to the Timestamp column.

If we attempt the very same update not using WCF, it works fine. So the issue must be with WCF. We have the proper [DataMember] attribute on the Timestamp property for serialization. Anyone have any idea what the issue might be?

Thanks for your help.

Randy

A: 

The issue has nothing to do with WCF, really.

Is it really a SQL Server TIMESTAMP data type??

You cannot update those - SQL Server will automatically updates those fields whenever something happens to the row.

See here "Timestamps vs. Datetime data types" or here "Misunderstanding timestamp" for more details.

How do you handle the update of the Linq-to-SQL data, when receiving that WCF message? Can you show us some code for that?

For instance: is that field/property defined as a read-only property on the data contract?? There's really no point in anyone trying to update that value....

Also, since you're sending the entities via WCF, those will be "disconnected" entities to Linq-to-SQL, e.g. entities that haven't been inside the scope of a DataContext at all times. This might lead to the effect that Linq-to-SQL wants to add a new entity with a new value for the timestamp column to your database....

marc_s
Yes it really is a Timestamp data type. And I believe it is a WCF issue because updates work fine when not using WCF. Besides, L2S knows not to attempt to update this column in SQL Server because it's marked as an Auto Generated Value.
Randy Minder
well, then something must be wrong in your code which tries to update the L2S entities from your WCF service - can you show us that code??
marc_s