Transfer options in DataTable F #
let dataTable = new DataTable("mytable")
dataTable.Columns.Add("bool_option_column") //typeof<bool option>
dataTable.Columns.Add("int_column")
I have a boolean column of options. How to enable storing null values in my SQL database when "myBooleanOption" is "None"?
dataTable.Rows.Add(
myBooleanOption,
myInt)
Note that the following is optional (I need null values):
dataTable.Rows.Add(
myBooleanOption |> Option.getValueOr false,
myInt)
Here is what I tried:
let nullToOpt = function
| None -> new System.Nullable<_>()
| Some x -> new System.Nullable<_>(x)
dataTable.Rows.Add(
myBooleanOption |> nullToOpt,
myInt)
To convert an option to a value with a zero value. This does not work.
Please let me know if you have any suggestions. Thanks