Skip to content

v2.0.8

Compare
Choose a tag to compare
@JonathanMagnan JonathanMagnan released this 30 Oct 18:21
· 19 commits to master since this release

Download the library here

  • ADDED: DefaultValueResolution and DefaultValueSql options

DefaultValueResolution

When DefaultValueResolution = DefaultValueResolutionType.Null, all null values will be automatically modified by the column default value (or the DefaultValueSql if one is spcified).

DapperPlusManager.Entity<TableWithDefaultValue>().Table("TableWithDefaultValue")
	.DefaultValueResolution(DefaultValueResolutionType.Null)
	.Identity(x => x.TableWithDefaultValueID);

Online Example: https://dotnetfiddle.net/Bo61Ic

DefaultValueResolution per Property

It's also possible to enable/disable this option for a specific property

DapperPlusManager.Entity<TableWithDefaultValue>().Table("TableWithDefaultValue")
	.DefaultValueResolution(x => x.ColumnInt1, DefaultValueResolutionType.Null)
	.Identity(x => x.TableWithDefaultValueID);

Online Example: https://dotnetfiddle.net/tetqH5

DefaultValueSql

You can now set a default value (a sql) to override the database default when using with DefaultValueResolution

DapperPlusManager.Entity<TableWithDefaultValue>().Table("TableWithDefaultValue")
	.DefaultValueResolution(DefaultValueResolutionType.Null)
	.DefaultValueSql(x => x.ColumnInt1, "1000")
	.Identity(x => x.TableWithDefaultValueID);

Online Example: https://dotnetfiddle.net/dHdPH4

Trial unlocked for the current month (November)