ExtensionMethod.NET Home of 875 C#, Visual Basic, F# and Javascript extension methods

IDataReader.ToDataSet

Converts an IDataReader into a DataSet, without requiring a DataAdapter.

Source

namespace Foo

open System.Data

[<AutoOpen>]
module FsDataEx =

    type System.Data.IDataReader with
        /// Populates a new DataSet with the contents of the reader. Closes the reader after completion.
        member this.ToDataSet () =
use reader = this
let dataSet = new DataSet(RemotingFormat=SerializationFormat.Binary, EnforceConstraints=false)
dataSet.Load(reader, LoadOption.OverwriteChanges, [| "" |])
dataSet

Example

let ds = reader.ToDataSet()

Author: Joel Mueller

Submitted on: 29 okt 2010

Language: F#

Type: System.Data.IDataReader

Views: 4205