No mapping exists from object type System.Collections.Generic.List when executing stored proc with parameters in EF 4.3

后端 未结 7 1484
旧巷少年郎
旧巷少年郎 2020-12-30 19:30

Lately I\'ve been working on stored procedure and encountered 1 strange problem.

First, I was able to successfully call a stored procedure from the database via:

7条回答
  •  梦毁少年i
    2020-12-30 20:25

    If the stored procedure is only for update/insert, the following can be used as well.

    string cmd = Constants.StoredProcs.usp_AddRoles.ToString() + " @userId, @roleIdList";
    int result = db.Database
                            .ExecuteSqlCommand
                            (
                               cmd,
                               new SqlParameter("@userId", userId),
                               new SqlParameter("@roleIdList", roleId)
                            );
    

提交回复
热议问题