FruityFoundation/FruityFoundation.DataAccess.Abstractions.FSharp/ReadOnlyDb.fs

36 lines
1.8 KiB
Forth
Raw Normal View History

[<RequireQualifiedAccess>]
module FruityFoundation.DataAccess.Abstractions.FSharp.ReadOnlyDb
open System.Collections.Generic
open System.Threading
open FSharp.Control
open FruityFoundation.DataAccess.Abstractions
let private toKeyValuePair (parms : (string * obj) seq) =
parms
|> Seq.map (fun (name, value) -> KeyValuePair(name, value))
let query<'a> (connection : IDatabaseConnection<ReadOnly>) (cancellationToken : CancellationToken) (sql : string) (parms : (string * obj) seq) = task {
return! connection.Query<'a>(sql, parms |> toKeyValuePair, cancellationToken)
}
let queryUnbuffered<'a> (connection : IDatabaseConnection<ReadOnly>) (cancellationToken : CancellationToken) (sql : string) (parms : (string * obj) seq) = taskSeq {
yield! connection.QueryUnbuffered<'a>(sql, parms |> toKeyValuePair, cancellationToken)
}
let querySingle<'a> (connection : IDatabaseConnection<ReadOnly>) (cancellationToken : CancellationToken) (sql : string) (parms : (string * obj) seq) = task {
return! connection.QuerySingle<'a>(sql, parms |> toKeyValuePair, cancellationToken)
}
let execute (connection : IDatabaseConnection<ReadOnly>) (cancellationToken : CancellationToken) (sql : string) (parms : (string * obj) seq) = task {
return! connection.Execute(sql, parms |> toKeyValuePair, cancellationToken)
}
let executeScalar<'a> (connection : IDatabaseConnection<ReadOnly>) (cancellationToken : CancellationToken) (sql : string) (parms : (string * obj) seq) = task {
return! connection.ExecuteScalar<'a>(sql, parms |> toKeyValuePair, cancellationToken)
}
let executeReader (connection : IDatabaseConnection<ReadOnly>) (cancellationToken : CancellationToken) (sql : string) (parms : (string * obj) seq) = task {
return! connection.ExecuteReader(sql, parms |> toKeyValuePair, cancellationToken)
}