Question from the Entity Framework test

How to get the first row of a SqlDataReader in C#

Hard

You are using Visual Studio 2010 and the .NET Framework 4.0 to create an application. This application connects to a SQL Server 2008 database. The database has a table dbo.Documents that contains a column with binary data. You are creating the data access layer.

You add the following code to query the dbo.Documents table.

01 public void LoadDocuments(DbConnection cnx)

02 {

03 var cmd = cnx.CreateCommand();

04 cmd.CommandText = "SELECT * FROM dbo.Documents";

05 ...

06 cnx.Open();

07

08 ReadDocument(reader);

09 }

You need to ensure that the data can be read into a stream (System.IO.Stream). What line of code should you insert at line 07?

Author: Guillaume BroutStatus: PublishedQuestion passed 196 times
Edit
0
Community EvaluationsNo one has reviewed this question yet, be the first!