Question

I am converting a legacy application which uses SQL Server and I want to use petapoco for my data access layer.

The tables definitions contains a lot of columns with DEFAULT values.

I would like my DAL to handle the default value when I insert new records.

Unfortunatey, using the ResultColumn attribute is not a solution because the column is discarded when I use UPDATE and INSERT. A DEFAULT value does not act exactly as a readonly calculated field.

Is there a way to handle this ?

Was it helpful?

Solution

There currently isn't a way because if the value is set to null then it will insert/update the value to DBNull.

There would have probably have to be a change to the code to have a new attribute eg. [OmitColumnIfDefaultValue] then if the value of that column equaled the default CLR value, then we could omit the column from the insert statement.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top