I've trawled through lots of similar questions and responses but couldn't find what I need so I'd appreciate any help.
I have the stored procedures in the database and it executes fine in SSMS. It is in the model browser for the .edmx
:
This is the code that throws the error.
private thisContext db = new thisContext();
var UserId = User.Identity.GetUserId();
var SelectFullProfile = true;
List<UsersSelectProfile_Result> profilelist = null;
profilelist = db.Database.SqlQuery<UsersSelectProfile_Result>(
"dbo.UsersSelectProfile @UserID={0}, @SelectFullProfile={1}",
UserId, SelectFullProfile).ToList();
Thanks for any help.
Looking at the ReadDataUsingStoredProcedure() example at this project
referred to on this tutorial
I think your call should be something like
var profileList = db.UsersSelectProfile(0,1);
You were trying execute a query which was stored procedure. But you were missing a keyword like 'EXEC'. Just add the keyword 'EXEC' before your procedure name then try to execute. It should be work.
It was, as I suspected, all to do with the entity framework, although sorry I cannot pinpoint the issue. I resolved it by regenerating the .edmx, I guess the first time left some corruption in the .edmx
And just for clarity, I didn't need to make any changes to the way I was calling the SPs at all.
I am very grateful to all those who were so forthcoming in their assistance
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.