相关疑难解决方法(0)

使用它登录功能或功能?

它是最好的(我知道没有银弹,但通过使用一个可能有一些优势) - 登录调用函数,或调用它的函数?

例子:

方法1


module MongoDb =
   let tryGetServer connectionString =
      try
         let server = new MongoClient(connectionString).GetServer()
         server.Ping()
         Some server
      with _ -> None
Run Code Online (Sandbox Code Playgroud)

用法:

match MongoDb.tryGetServer Config.connectionString with
| None ->
    logger.Information "Unable to connect to the database server."
    // ... code ...
| Some srv ->
    logger.Information "Successfully connected to the database server."
    // ... code ...
Run Code Online (Sandbox Code Playgroud)

方法2


module MongoDb =
    let tryGetServer connectionString =
        try
            let server = new MongoClient(connectionString).GetServer()
            server.Ping()
            Some server
        with …
Run Code Online (Sandbox Code Playgroud)

f#

4
推荐指数
1
解决办法
652
查看次数

标签 统计

f# ×1