0

According to MSDN (http://msdn.microsoft.com/en-us/library/dd487208.aspx), there is an object called DbDataReader that is created in the process of running a SQL query in Entity Framework.

Entity Framework "translates" the DbDataReader into a entity class.

How can I access the DbDataReader directly?

1
  • I was hoping that there is some way to access the values returned from SQL directly while still having the benefit of having EF manage connections and all the rest. Commented May 8, 2012 at 22:11

1 Answer 1

1

You can access the data reader it if you execute the query yourself:

using (var command = context.Connection.CreateCommand())
{
    command.CommandText = "SELECT ...3;
    using (var reader = command.ExecuteReader())
    {
        ...
    }
}
Sign up to request clarification or add additional context in comments.

1 Comment

This sort of works. I'm disappointed to see that I still must manually open and close the connections, tho.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.