This is a migrated thread and some comments may be shown as answers.

Database default value assignment problem

4 Answers 67 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
John
Top achievements
Rank 1
Iron
John asked on 20 Oct 2014, 02:25 AM
Hi,
I'm trying to insert an object having the database supply the default for the columns with unspecified values. For the table in question, the proper fields are all have their HasDefaultValue and IsNullable as true on the meta-column and Nullable=True in the Domain Class's property. During the SaveChanges, however, I see all of the fields in the insert statement. Is there something else I'm missing?


John



4 Answers, 1 is accepted

Sort by
0
Thomas
Telerik team
answered on 21 Oct 2014, 06:24 AM
Currently we do not support default values from the database side; you will need to resort storing the same value from the client side instead.

Regards,
Thomas
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
0
John
Top achievements
Rank 1
Iron
answered on 21 Oct 2014, 11:50 AM
Thanks Thomas
If this is the case, what functionality this link is referred to http://docs.telerik.com/data-access/developers-guide/data-access-domain-model/domain-class-mapping/data-access-tasks-define-model-class-mapping-default-values

Regards, John
0
Accepted
Thomas
Telerik team
answered on 24 Oct 2014, 10:25 AM
Hi John,

my mistake, didn't remember that we implemented that. I tried this here with a string column where I specified in the fluent mapping .HasDefaultValue(). This worked, and the column was omitted from the insert statement.

Which mapping are you using?

Regards,
Thomas
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
0
John
Top achievements
Rank 1
Iron
answered on 24 Oct 2014, 02:44 PM
I used a database-first to start the model, although to expedite things, I've messed with the rlink file directly which worked for most part but I could have screwed something up. Also, upon further review, it turned out we can't use the database defaults the way they are implemented since null values carry a significance for the application. Thanks for your response though.

Regards, John
Tags
Development (API, general questions)
Asked by
John
Top achievements
Rank 1
Iron
Answers by
Thomas
Telerik team
John
Top achievements
Rank 1
Iron
Share this question
or