Creating Entity Framework Objects from Stored Procedures

When using Entity Framework 4, how do you create a single entity from a stored procedure?

Answers


After you add the stored procedure to the model, from the Model Browser right-click the stored procedure under the Store node and select 'Add Function Import'. In that dialog, indicate what entity should be created:

You can then use that stored procedure like this:

Artist a = ctx.SelectArtist(id).SingleOrDefault();

Edit

Based on the comments, it sounds like you want to use stored procedures to perform inserts, updates, and deletes. If you right-click on the entity in the model browser and select 'Stored Procedure Mapping', you'll get a window that lets you specify which stored procedures to use. MSDN has a walkthrough on how to do this.

HTH


Need Your Help

How to reduce the logservice RPC's in google app engine backends

google-app-engine rpc backend

above is the image of appstats of a single GET request to my app, this image shows the RPC traces of a single logservice RPC do the number of loservice calls effect the app negatively, for 5

How to get unicode character http response in blackberry?

http blackberry unicode

I have an api that response with json data which contains malayalam unicharacter and english unicharacter also.