SubSonic Forums
All Your Database Are Belong To Us

Problem updating a RepositoryRecord that has just been added

Latest post 05-02-2008 5:11 AM by stefana62. 0 replies.
  • 05-02-2008 5:11 AM

    • stefana62
    • Top 500 Contributor
    • Joined on 02-01-2008
    • Gothenburg, Sweden
    • Posts 8

    Problem updating a RepositoryRecord that has just been added

    Hi,

    When using the RepositoryRecord templates it is not possible to insert a new record and then update a field:

    RecordType r = new RecordType();
    r.Field1 = "val1";
    r.Field2 = "val2";
    DB.Save(r);
    r.Field2 = "new val 2";
    DB.Save(r): // This will not update Field2 in the database

    I think the problem is in RecordBase.cs line 311: 

             /// <summary>
            /// Sets a value for a particular column in the record
            /// </summary>
            /// <param name="columnName">Name of the column, as defined in the database</param>
            /// <param name="oValue">The value to set the type to</param>
            public void SetColumnValue(string columnName, object oValue)
            {
                columnSettings = columnSettings ?? new TableSchema.TableColumnSettingCollection();
                //add the column to the DirtyColumns
                //if this instance has already been loaded
                //and this is a change to existing values
                if(IsLoaded && !IsNew) // Shouldn't this be: if(IsLoaded || !IsNew)
                {
                    TableSchema.Table schema = GetSchema();
                    object oldValue = null;
                    string oldValueMsg = "NULL";
                    string newValueMsg = "NULL";
                    bool areEqualOrBothNull = false;

    Regards,

    Stefan 

    //Stefan
Page 1 of 1 (1 items) | RSS