我使用实体框架将表添加到我的解决方案中。
请告诉我如何在实体框架中调用存储过程。
我像往常一样直接打电话给SP,但是没有调用它。
[WebInvoke(UriTemplate = "LoginValidation?emailid={emailid}&password={password}&id={id}", Method = "POST")]
public string Insert(string emailid, string password, string aid)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DataEntities"].ConnectionString);
// Validation validation = new Validation();
try
{
SqlCommand cmd = new SqlCommand("VerifyAndRetreiveUser", con);
con.Open();
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@emailid", SqlDbType.VarChar).Value = emailid;
cmd.Parameters.Add("@password", SqlDbType.VarChar).Value = password;
cmd.Parameters.Add("@id", SqlDbType.Int).Value = Convert.ToInt32(id);
cmd.Parameters.Add("@result", SqlDbType.VarChar).Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
string result = cmd.Parameters["@result"].ToString();
return result;
}
catch (Exception exc)
{
string msg = "Exception occured while validating user. " + exc.Message;
if (exc.InnerException != null)
msg += exc.InnerException.Message;
return msg;
}
}
该存储过程未在实体框架中调用.pls帮助我