0

I am manually calling a stored procedure using an Entity Framework EntityConnection like so:

DbConnection storeConnection = entityConnection.StoreConnection;
DbCommand command = storeConnection.CreateCommand();
command.CommandText = "sp_GetMyComplexData";
command.CommandType = CommandType.StoredProcedure;

DbDataReader reader = command.ExecuteReader();

The reason for this is that the entity framework doesn't easily support entities that don't directly map to tables or views. I found this article (http://dotnet.dzone.com/news/mapping-stored-procedure), but it requires editing of the XML, which I would like to avoid.

In my case I'm just running a query that joins two tables using a LEFT JOIN. The reason for THAT is because I am trying to bind the results to a Telerik RadGrid, which doesn't support hierarchical data exports, but does seem to support grouped data exports.

The problem is, how do I convert the DbDataReader object into something useful that I can bind to my RadGrid? I've been passing around single objects, or IQueryable objects in my DAL methods. Any ideas? Thanks in advance?

EDIT:

I only need the data. I don't need to do any inserts, updates, deletes afterwards. Its a read-only view.

1 Answer 1

1

I don't know about RadGrid, but you can bind that datareader to the built-in grid controls like GridView. You just can't use it for updates, deletes, or inserts.

Otherwise, you could turn it into a datatable using the datatable's .Load() method. But you'll still need to know how to do the insert/update/deletes manually.

Sign up to request clarification or add additional context in comments.

1 Comment

I thank table.Load(reader); is what I am looking for. I'll let you know how it goes...

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.