-
Notifications
You must be signed in to change notification settings - Fork 1
Executing queries
Jacek Hełka edited this page Mar 20, 2024
·
4 revisions
Query functions, defined with DbFun, return DbCall<'Result>, that is function taking IConnector parameter (object carrying database connection and optionally transaction) and returning data wrapped in Async.
Such function can be executed by passing it to the run function defined in the Configuration section:
let blog = getBlog id |> DB.runTo execute more queries on one open connection the dbsession computation expression can be used:
dbsession {
let! postId = insertPost p
do! insertTags postId p.tags
}
|> DB.runQueries can also be executed transactionally:
dbsession {
let! postId = insertPost p
do! insertTags postId p.tags
}
|> DbCall.InTransaction
|> DB.runWith a certain isolationlevel:
dbsession {
let! postId = insertPost p
do! insertTags postId p.tags
}
|> DbCall.InTransactionWith IsolationLevel.RepeatableRead
|> DB.run