Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You don't need to worry about this. SubSonic is intelligent enough to handle this!</p> <p>Just create new object assign values to properties and save it.</p> <pre><code>var o = new DataObject(); o.Name="Foo"; o.Age = 20; //o.RowVersion = ....; DON'T ASSIGN THIS o.Save(); </code></pre> <p>EDIT:- Here is what I've tried:</p> <p>Table Definition:</p> <pre><code>CREATE TABLE [dbo].[TestTimeStamp]( [RowID] [int] IDENTITY(1,1) NOT NULL PRIMARY KEY, [Description] [nvarchar](50) NOT NULL, [RowVersion] [timestamp] NOT NULL ) </code></pre> <p>Code:</p> <pre><code>private static void Test() { var o = new TestTimeStamp(); o.Description = "Hello World"; o.Save(); } </code></pre> <p><strong>FIXED</strong>:- 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 <code>IsReadOnly</code> 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 to <code>Structs.tt</code> file's <code>for</code> loop which adds columns to table classes :) . To fix find the following loop (it starts at line 30)</p> <pre><code>&lt;# foreach(var col in tbl.Columns){#&gt; Columns.Add(new DatabaseColumn("&lt;#=col.Name#&gt;", this) { </code></pre> <p>and change initialization of new DatabaseColumn to as follows:</p> <pre><code> Columns.Add(new DatabaseColumn("&lt;#=col.Name#&gt;", this) { IsPrimaryKey = &lt;#=col.IsPK.ToString().ToLower()#&gt;, DataType = DbType.&lt;#=col.DbType.ToString()#&gt;, IsNullable = &lt;#=col.IsNullable.ToString().ToLower()#&gt;, AutoIncrement = &lt;#=col.AutoIncrement.ToString().ToLower()#&gt;, IsForeignKey = &lt;#=col.IsForeignKey.ToString().ToLower()#&gt;, //THIS LINE DO THE TRICK. IsReadOnly = &lt;#=col.DataType.ToLower().Equals("timestamp") .ToString().ToLower() #&gt; }); </code></pre> <p>PS:- Please get subsonic srouce from <a href="http://github.com/amantur/SubSonic-3.0" rel="nofollow noreferrer">here</a>. In the previous version only null and <code>AutoIncrement</code> is checked on inclusion into Add and Update column list, but this code checks for ReadOnly property also.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload