Execute non-query procedure not working asp.net core

血红的双手。 提交于 2019-12-04 21:15:15

Take help from this link https://docs.microsoft.com/en-us/ef/core/querying/raw-sql

In Core 2.0 or EntityFramework 7 does not support SqlQuery feature which was available in previous version of ef 6.

Below is the example how you can execute sp in EntityFramework 7.

 public List<UserDetails> GetUserDetailsUsingSP(int LoggedInID)
        {
            var loggedInUser = new SqlParameter("Id", LoggedInID);

            return WidServices
                .FromSql("EXECUTE WID_Services_GetAll  @Id ", loggedInUser)
                .FirstOrDefault();
        }

Note : Add this method where you are adding your DbSet under your main db context class and then call this method by instantiating your dbContext.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!