I have the following code:
let getByIdAsync (connectionString : string) (id : int) =
let sql = @"SELECT * FROM [User] WHERE [Id] = @id"
let args = [ "id" => id ]
async {
use connection = new SqlConnection(connectionString)
do! connection.OpenAsync() |> Async.AwaitTask
try
use! reader = connection.ExecuteReaderAsync(sql, args) |> Async.AwaitTask
return reader |> mapRowsToRecords |> Seq.head
with
| e -> return Error e.Message
}
This code throws MultiExec is not supported by ExecuteReader
and I have no idea why. Other queries (like my insert for example) work just fine. What am I doing wrong?