How to get a DbDataReader object directly in Entity Framework?

1.4k Views Asked by At

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

There are 1 best solutions below

1
On BEST ANSWER

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())
    {
        ...
    }
}