开发者

Creating Entity Framework Objects from Stored Procedures

When using Entity Framework 4, how开发者_如何学编程 do you create a single entity from a stored procedure?


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:

Creating Entity Framework Objects from Stored Procedures

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜