File tree Expand file tree Collapse file tree 1 file changed +6
-10
lines changed
frameworks/FSharp/oxpecker/src/App Expand file tree Collapse file tree 1 file changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -32,20 +32,15 @@ module Db =
3232 cmd.Parameters.Add( id) |> ignore
3333 struct ( cmd, id)
3434
35- let private readSingleRow ( cmd : NpgsqlCommand ) =
36- task {
37- use! rdr = cmd.ExecuteReaderAsync( CommandBehavior.SingleRow)
38- let! _ = rdr.ReadAsync()
39- return { id = rdr.GetInt32( 0 ); randomnumber = rdr.GetInt32( 1 ) }
40- }
41-
4235 let loadSingleRow () =
4336 task {
4437 use db = new NpgsqlConnection( ConnectionString)
4538 let struct ( cmd' , _ ) = createReadCommand db
4639 use cmd = cmd'
4740 do ! db.OpenAsync()
48- return ! readSingleRow cmd
41+ use! rdr = cmd.ExecuteReaderAsync( CommandBehavior.SingleRow)
42+ let! _ = rdr.ReadAsync()
43+ return { id = rdr.GetInt32( 0 ); randomnumber = rdr.GetInt32( 1 ) }
4944 }
5045
5146 let private readMultipleRows ( count : int ) ( conn : NpgsqlConnection ) =
@@ -54,8 +49,9 @@ module Db =
5449 let struct ( cmd' , idParam ) = createReadCommand conn
5550 use cmd = cmd'
5651 for i in 0 .. result.Length-1 do
57- let! row = readSingleRow cmd
58- result[ i] <- row
52+ use! rdr = cmd.ExecuteReaderAsync( CommandBehavior.SingleRow)
53+ let! _ = rdr.ReadAsync()
54+ result[ i] <- { id = rdr.GetInt32( 0 ); randomnumber = rdr.GetInt32( 1 ) }
5955 idParam.TypedValue <- Random.Shared.Next( 1 , 10001 )
6056 return result
6157 }
You can’t perform that action at this time.
0 commit comments