I need to insert a record to a table.
Subsonic builds the query something like this (as far as i know):
INSERT INTO Table1
(Title, Description, RowVersion)
VALUES
(@Title, @Description, @RowVersion)
But i want to remove the RowVersion column from the SQL query bacause its autogenerated by the sql server.
How can i do that?
Best Answer
You don't need to worry about this. SubSonic is intelligent enough to handle this!
Just create new object assign values to properties and save it.
EDIT:- Here is what I've tried:
Table Definition:
Code:
FIXED:- Yippe, I spinned my head over the cause, as this has never happened in SubSonic 2. I branched SubSonic 3 code, but there was not anything to find. Then after much fooling around I once again examined T4 templates. Some how the
IsReadOnly
property is not being set but it is checked when cretaing insert, update queries in SubSonic.Extension.Object.cs class. So the solution is to add a line toStructs.tt
file'sfor
loop which adds columns to table classes :) . To fix find the following loop (it starts at line 30)and change initialization of new DatabaseColumn to as follows:
PS:- Please get subsonic srouce from here. In the previous version only null and
AutoIncrement
is checked on inclusion into Add and Update column list, but this code checks for ReadOnly property also.