I am new in F#. So that I face some problem in my project.
let getTotalNoOfSmsPerDay (Db cStr) =
use cmd = new SqlCommandProvider<"select COUNT(id) as NoOfSMS
from transport.SmsNotification
where CONVERT(date, CreatedOn) = CONVERT(date, GETDATE())
",ConnectionString, SingleRow = true>(cStr)
async {
let! result = cmd.AsyncExecute()
return result
}
This is my Code. I just want a integer number NoOfSMS . But It gives me <Option<int>>
How can I solve this?
Thanks in advance
Option
represents that nothing may be returned. This is the point where most other languages would return null
.
There are a few ways to use the value inside Option
. Explore the functions available.
Often what you will do though is to match
on the 2 cases ie. Some
value was returned or None
.
match result with
| Some v -> v
| None -> 0
Here are some links to tutorials I have written on the topics.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.