Hello everyone,
I am trying to "insert" new record to the database using following code:
using System; using Castle.ActiveRecord; using System.Collections.Generic;
namespace TMS { [ActiveRecord("TMSConstructionSchema")] public class TMSConstructionSchema { #region Private Members private long _iSchemaID; private string _description = string.Empty; #endregion
#region Public Properties [PrimaryKey(PrimaryKeyType.Assigned, "iSchemaID")] public long SchemaID { get { return _iSchemaID; } set { _iSchemaID = value; } }
[Property("Description")] public string Description { get { return _description; } set { _description = value; } } #endregion } }
Everything seems to be ok with this code, but once I change the [PrimaryKey(PrimaryKeyType.Assigned, "iSchemaID")] attributes (PrimaryKeyType) to any other (native, customgenerator - either increment) I got the following exception:
Unexpected row count: 0; expected: 1
I am using Save or Create (Create - first of all) method to "save" new data to the DB. At the beginning of the project development the ID was defined as identity and everything worked fine with [PrimaryKey("iSchemaID")] (I mean Save and Create).
Changing it to put some unique bigint value makes problems.
Reading from the DB works fine with any of PrimaryKeyType's.
What I am doing wrong?
_________________ www.jurasz.net
|