Questions tagged [idatareader]

IDataReader is a Microsoft .NET interface which can be used to read data coming from a database. Use this tag for questions about using this interface.

Provides a means of reading one or more forward-only streams of result sets obtained by executing a command at a data source, and is implemented by .NET Framework data providers that access relational databases.

References:

Related questions/examples:

Also see .

120 questions
4
votes
2 answers

How to deal with option values generically in F#

I'm writing a adapter class to map IEnumerable<'T> to IDataReader the full source is at https://gist.github.com/jsnape/56f1fb4876974de94238 for reference but I wanted to ask about the best way to write part of it. Namely two functions: member…
James
  • 433
  • 4
  • 14
4
votes
5 answers

How to invoke a method which returns an interface

I am invoking a method on a type via reflection which takes a couple of parameters: var myType = typeof(myClass); var myMethod = myType.GetMethod("myMethodInClass", new[] { typeof(string), typeof(string)…
Daniel Billingham
  • 1,391
  • 5
  • 15
  • 25
4
votes
2 answers

Does IDataReader.Dispose() close the connection?

The typical query execution pattern I inherited is like so: using (IDataReader r = query.ExecuteReader()) { while (r.Read()) { // etc. } } Is query.Connection left open after the using block is exited?
svidgen
  • 13,744
  • 4
  • 33
  • 58
3
votes
3 answers

IDataReader.GetOrdinal or IDataReader[ColumnName]

I have two cases to extract information from the IDataReader object Case - 1 - Length, calculates ordinal and then parse string public static string GetString(IDataReader rdr, string columnName) { int ordinal = rdr.GetOrdinal(columnName); if…
Pankaj
  • 9,749
  • 32
  • 139
  • 283
3
votes
4 answers

Should IDataReader::Dispose call IDataReader::Close?

I'm implementing IDataReader and I wonder if the implementation of Dispose is supposed to call Close or not. Also, should Close call Dispose? My guess is that Close shouldn't call Dispose and Dispose can call Close since AFAIK you should be able to…
Juan
  • 15,274
  • 23
  • 105
  • 187
3
votes
3 answers

c#, interface, assignment

I have a question. Interface does not hold any definition. Interface can not be instantiated. How can this code be valid ? IDataReader reader = cmd.ExecuteReader() cmdExecuteReader returns an object with a value in memory. reader is interface. How…
avast
  • 31
  • 2
3
votes
2 answers

How to convert IDataReader into Stream in C#

In my WCF service, I am retrieving data from SQL server using Command.ExecuteReader() method. The data size is very large (around 1+ GB) and transferring this data to client over netTcp binding. I am planning to implement stream mode instead of…
Abhash786
  • 881
  • 2
  • 24
  • 53
3
votes
2 answers

Supplying stream as a source of data for a binary column when SqlBulkCopy is used

If one needs to read data from SqlServer in a streamed fashion, there are some capabilities for that. Such as using SqlDataReader with CommandBehavior.SequentialAccess, and particularly when binary column data needs to be accessed there is the…
i-one
  • 5,050
  • 1
  • 28
  • 40
3
votes
3 answers

Checking for Nulls on DB Record Mapping

How can I check for db null values in the attached code? Please understand I am a new C# convert... What this code does is takes a IDataReader object and converts and maps it to a strongly-typed list of objects. But what I am finding is it…
Kevin
  • 2,684
  • 6
  • 35
  • 64
3
votes
2 answers

CBO.FillCollection throwing "No parameterless constructor defined for this object." error

I'm trying to fill a collection from an IDataReader that was returned by another method... for some reason it keeps throwing a "No parameterless constructor defined for this object." error for this line: List names =…
Matt
  • 5,547
  • 23
  • 82
  • 121
3
votes
5 answers

Improving DAL performance

The way i currently populate business objects is using something similar to the snippet below. using (SqlConnection conn = new SqlConnection(Properties.Settings.Default.CDRDatabase)) { using (SqlCommand comm = new SqlCommand(SELECT, conn)) …
Ant Swift
  • 20,089
  • 10
  • 38
  • 55
2
votes
3 answers

Convert C# lambda function to VB.net

I have this function that maps a IDataReader to a class. It is obviously written in C#. My co-worker wants to use the same method in his code, but he is writing in VB.net. Basically I am having difficulty rewriting this due to the Lambda…
jejernig
  • 319
  • 2
  • 8
2
votes
1 answer

Converting Kusto client response to list of objects returns empty objects

I am trying to convert the response received from running a Kusto query in which I am retrieving the schema of a table. My Kusto query looks like this: tableName | getschema The response for such a query, as seen in the Kusto Explorer looks…
Liviu
  • 1,023
  • 2
  • 12
  • 33
2
votes
2 answers

AutoMapper with a list data from IDataReader

using (IDataReader dr = DatabaseContext.ExecuteReader(command)) { if (dr.Read()) { AutoMapper.Mapper.CreateMap(); return AutoMapper.Mapper.Map
vNext
  • 1,102
  • 4
  • 16
  • 28
2
votes
1 answer

IDataReader that returns multiple IDataRecords for each object in the input list

I am trying to implement the fastest way of importing millions of rows into a SQL table via use of the SqlBulkCopy function and providing it with a custom IDataReader (I am told this would be faster than trying to create a DataTable) I currently…
jh_dempsey
  • 39
  • 3