I have a model that has the following property:
public int AccountNumber {
get => _AccountNumber;
set {
CompareChange(_AccountNumber, value);
_AccountNumber = value;
}
}
The table in SQL (SQL Server) has a default set for that column such that it returns the next number from a sequence.
[AccountNumber] INT NOT NULL DEFAULT next value for AccountNumberSequence
How do I enable the following through OrmLite:
- When saving a new model, the update statement must not send through the
AccountNumber
field for this specific POCO. This will allow the database to set it’s default value. I tried to make itint?
but the field is marked as non-nullable and the update statement will try to set the field tonull
which throws a SQLException. I cannot make it aprivate set
as this property may actually be set somewhere else. - This value must still be retrieved from the database when doing a select.
- On Save for the first time, how do I get the default value set by the database back? Will I need to make another query?
Any ideas on how to accomplish this?
I am using OrmLite 4.5.12.