I know it's a stupid question, but I could not find the answer anywhere. How to set a default value for a column in sqlite.net model? Here is my model class:
public class ItemTaxes
{
[PrimaryKey]
public string Sku { get; set;}
public bool IsTaxable { get; set;}// How to set IsTaxable's default value to true?
public decimal PriceTaxExclusive { get; set;}
}
I wanna set default value of Not Null column IsTaxable to true, how should I achieve that? Btw I do not want use raw sql statement, i.e. conn.execute();
Thank you.
A little late, but for those who got here looking for an answer:
public class ItemTaxes
{
[NotNull, Default(value: true)]
public bool IsTaxable { get; set; }
}
If the Default attribute isn't available in the version of SQLite-net that you're using, you can use autoproperties to assign a default like you normally would.
public class ItemTaxes
{
public bool IsTaxable { get; set; } = true;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With