Hello,
楼主你用的什么版本的EF,如果是EF5或以上的话,调用存储过程只需要在model里直接选择update model from database,然后选择你要调用的存储过程名称就可以了.
如果楼主用的是之前的版本,那需要在edmx文件里定义好的:
<Function Name="GetCountByLastName" Aggregate="false" BuiltIn="false"
NiladicFunction="false" IsComposable="false"
ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
<Parameter Name="LastName" Type="nvarchar" Mode="In" />
<Parameter Name="LastNameCount" Type="int" Mode="InOut" />
</Function>
在代码里:
public ObjectResult<FirstNameAndCompany> GetCountByLastName
(global::System.String lastName, ObjectParameter lastNameCount)
{
ObjectParameter lastNameParameter;
if (lastName != null)
{
lastNameParameter = new ObjectParameter("LastName", lastName);
}
else
{
lastNameParameter = new ObjectParameter("LastName", typeof(global::System.String));
}
return base.ExecuteFunction<FirstNameAndCompany>
("GetCountByLastName", lastNameParameter, lastNameCount);
}
Regards.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.