I can't figure out what I am doing wrong I am new to this entity framework. I am just trying to call this simple stored procedure which returns one or none persons.
This is the error I get:
Cannot implicitly convert type 'System.Data.Objects.ObjectResult' to 'Model.Person'
Stored Procedure:
Create PROCEDURE [dbo].[GetPersonByID]
@personID int
AS
BEGIN
SELECT PersonID, FirstName, LastName, DOB, Notes, Reason, Diagnosis, DateEntered
FROM Person
WHERE PersonID = @personID
END
I updated my entity and see the stored procedure here. I also right clicked on my stored procedure and added a function import and tied it to the Person Entity.
Code:
private static Person GetPersonByID(int personID)
{
try
{
ModelEntities context = new ModelEntities();
return context.GetPersonByID(personID);
}
catch (Exception ex)
{
return null;
}
}