F# and ADO.NET - idiomatic F#

后端 未结 3 924
星月不相逢
星月不相逢 2021-02-04 01:55

I\'m just starting to learn F#. I wrote this F#/ADO.NET code last night. In what ways would you improve the syntax - make it feel like idiomatic F#?

    let cn =         


        
3条回答
  •  独厮守ぢ
    2021-02-04 02:17

    Well, there's not much you can change in the first bit but whenever you're processing collections of data like in the last few rows, you can use the built-in Seq, List, Array functions.

    for i in 0 .. (rowCount - 1) do
      let row:DataRow = rowCol.[i]
      printfn "%A" row.["LastName"]
    

    =

    rowCol |> Seq.cast 
           |> Seq.iter (fun row -> printfn "%A" row.["LastName"])
    

提交回复
热议问题