Entity Framework Stored Procedures and POCO

拥有回忆 提交于 2019-11-30 23:09:24

Yes, you can use the generic version of ExecuteStoreQuery once you get to the ObjectContext:

var listOfType= ((IObjectContextAdapter)context).ObjectContext
                    .ExecuteStoreQuery<Type>("SPROCNAME");

Here is the MSDN sample code (just change the TSQL to a sproc)

And, here is one that shows how to deal with parameters

The newer versions of EF has SqlQuery and DbContext.Database to get the ObjectContext easier:

var listOfType = context.Database.SqlQuery<Type>("SPROCNAME");
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!