Skip to content

Commit

Permalink
Merge pull request #145 from mickednk/use-prepareasync
Browse files Browse the repository at this point in the history
Use PrepareAsync for asynchronous calls
  • Loading branch information
rfrerebe authored Dec 7, 2024
2 parents 727214f + 1264ab8 commit deb8887
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Npgsql.FSharp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,8 @@ module Sql =
then do! connection.OpenAsync(props.CancellationToken)
use command = makeCommand props connection
do populateCmd command props
if props.NeedPrepare then command.Prepare()
if props.NeedPrepare then
do! command.PrepareAsync(props.CancellationToken)
use! reader = command.ExecuteReaderAsync props.CancellationToken
let postgresReader = unbox<NpgsqlDataReader> reader
let rowReader = RowReader(postgresReader)
Expand All @@ -482,7 +483,8 @@ module Sql =
then do! connection.OpenAsync(props.CancellationToken)
use command = makeCommand props connection
do populateCmd command props
if props.NeedPrepare then command.Prepare()
if props.NeedPrepare then
do! command.PrepareAsync(props.CancellationToken)
use! reader = command.ExecuteReaderAsync(props.CancellationToken)
let postgresReader = unbox<NpgsqlDataReader> reader
let rowReader = RowReader(postgresReader)
Expand All @@ -504,7 +506,8 @@ module Sql =
then do! connection.OpenAsync(props.CancellationToken)
use command = makeCommand props connection
do populateCmd command props
if props.NeedPrepare then command.Prepare()
if props.NeedPrepare then
do! command.PrepareAsync(props.CancellationToken)
use! reader = command.ExecuteReaderAsync props.CancellationToken
let postgresReader = unbox<NpgsqlDataReader> reader
let rowReader = RowReader(postgresReader)
Expand Down Expand Up @@ -547,7 +550,8 @@ module Sql =
then do! connection.OpenAsync props.CancellationToken
use command = makeCommand props connection
populateCmd command props
if props.NeedPrepare then command.Prepare()
if props.NeedPrepare then
do! command.PrepareAsync(props.CancellationToken)
let! affectedRows = command.ExecuteNonQueryAsync props.CancellationToken
return affectedRows
finally
Expand Down

0 comments on commit deb8887

Please sign in to comment.