MySQL 데이터베이스에서 EF4 모델을 생성했으며 StoredProcedures와 Tables를 모두 포함했습니다.EntityFramework로 저장 프로 시저를 호출하는 방법?
EF에 대해 정기적 인 instert/update/fetch/delete 작업을 수행하는 방법을 알고 있지만 StoredProcedures를 찾을 수 없습니다.
using (Entities context = new Entities())
{
context.MyStoreadProcedure(Parameters);
}
편집 : 1 :
이 그것이 EF없이 모습입니다 :
sqlStr = "CALL updateGame(?,?,?,?,?,?,?)";
commandObj = new OdbcCommand(sqlStr, mainConnection);
commandObj.Parameters.Add("@id,", OdbcType.Int).Value = inGame.id;
commandObj.Parameters.Add("@name", OdbcType.VarChar, 255).Value = inGame.name;
commandObj.Parameters.Add("@description", OdbcType.Text).Value = ""; //inGame.description;
commandObj.Parameters.Add("@yearPublished", OdbcType.DateTime).Value = inGame.yearPublished;
commandObj.Parameters.Add("@minPlayers", OdbcType.Int).Value = inGame.minPlayers;
commandObj.Parameters.Add("@maxPlayers", OdbcType.Int).Value = inGame.maxPlayers;
commandObj.Parameters.Add("@playingTime", OdbcType.VarChar, 127).Value = inGame.playingTime;
return Convert.ToInt32(executeScaler(commandObj));
PS를
이
내가 바라던 것이었다. 필요하다면 나는 EF 버전을 변경할 수 있습니다편집 1 :
CREATE DEFINER=`106228`@`%` PROCEDURE `updateGame`(
inId INT,
inName VARCHAR(255),
inDescription TEXT,
inYearPublished DATETIME,
inMinPlayers INT,
inMaxPlayers INT,
inPlayingTime VARCHAR(127)
)
나는 그것을 얻지 못한다. 왜 SP 이름을 하드 코드해야 하는가? 모델을 생성 할 때 추가했습니다. 컨텍스트 개체의 어딘가에 있지 않아야합니까? – Ivy