Entity Framework CTP5 - How to Call Stored Procedure?

删除回忆录丶 提交于 2019-11-30 13:13:24

You can execute database-wide sql statements like this

using(var context = new MyContext())
{
    // custum sql statement
    var c = context.Database.SqlQuery<int>("SELECT COUNT(*) FROM Employees");

    // returned entity type doesn't have to be represented by ObjectSet/DBSet
    var e = context.Database.SqlQuery<Employee>("SELECT * FROM Employees");

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