SqlCommand.AsyncMethods
A set of extension methods to allow asynchronous SqlClient operations to integrate with F# async workflows.
Source
namespace Foo
[<AutoOpen>]
module FsDataEx =
type System.Data.SqlClient.SqlCommand with
member this.AsyncExecuteNonQuery =
Async.FromBeginEnd(this.BeginExecuteNonQuery, this.EndExecuteNonQuery)
member this.AsyncExecuteReader() =
Async.FromBeginEnd(this.BeginExecuteReader, this.EndExecuteReader)
member this.AsyncExecuteReader(behavior : System.Data.CommandBehavior) =
Async.FromBeginEnd((fun (cb, state) -> this.BeginExecuteReader(cb, state, behavior)), this.EndExecuteReader)
member this.AsyncExecuteXmlReader() =
Async.FromBeginEnd(this.BeginExecuteXmlReader, this.EndExecuteXmlReader)
Example
async {
use! reader = someCommand.AsyncExecuteReader()
// do stuff with reader
}
Author: Joel Mueller
Submitted on: 29 okt. 2010
Language: F#
Type: System.Data.SqlClient.SqlCommand
Views: 4787