If your stored procedure is somehow similar to this
CREATE PROCEDURE [dbo].[sp_Get_Latest_Event]
AS
SELECT 'thisIsTheLatestEvent' AS EventTitle
, 'http://192.168.100.101:8080/rootdir/images/theEventImage.png' As EventImageUrl
GO
and you build your entity framework in a way as described here
Stored Procedure in Entity Framework[
^]
then you will have something generated like this
public partial class sp_Get_Latest_Event_Result
{
public string EventTitle { get; set; }
public string EventImageUrl { get; set; }
}
so the piece of code you are searching for should be like
void TestCallToStoredProc()
{
using (var context = new GaushalaDBEntities())
{
var lastestEventFromSp = context.sp_Get_Latest_Event();
var firstItem = lastestEventFromSp.FirstOrDefault();
Console.WriteLine(firstItem.EventTitle);
Console.WriteLine(firstItem.EventImageUrl);
}
}
What you get from the sp-call is a ObjectResult<t> where T is sp_Get_Latest_Event_Result
In case you set up things different, you should mention in your question
btw: if you are working with ms sql server naming a stored procedure with "sp_*" is not recommended