sapiens/SqlFu

Inserting a record into table with rowversion column in v3.3.5

Closed this issue · 4 comments

We have a table with rowversion column. When we try to insert a record, we receive the following exception:

Cannot insert an explicit value into a timestamp column. Use INSERT with a colimn list to exclude the timestamp column, or insert a DEFAULT into the timestamp column.

The problem should be solved with [QueryOnly] attribute, which is available in version 2 but is missing in the last version. How can we fix the problem? Is it possible to return [QueryOnly] attribute?

SqlServer type rowversion should be a byte[8] property of the POCO.

Yes, we use byte[8] property, but rowversion is auto-generated type in T-SQL and SqlFu try to set value on this field. The problem is that SqlFu doesn't ignore byte[8] property when do insert operation

Try this

 db.Insert(myData,opt=>opt.Ignore(c=>c.Version))

or you can remove that property from the POCO all together if you don't use it in your app i.e it's used only by the db.

The insert option did the job. Thank you