EntityFramework: stored procedure that returns a custom Poco instead of the complex type

advertisements

I have a Custom POCO (Already existing und used in my project).

public class MyPoco()
{
     public string MyPocoName {get; set;}
     public string MyPocoParentName {get; set;}
}

I have also a stored procedures that returns a list of (MyPocoName,MyPocoParentName) values.

I couldn't set MyPoco as the return type of this procedure in the Function import wizard.

I don't want to create a new custom type that have the same proporties as MyPoco.

Is there any way that could specify the return type of the stored procedure to be MyPoco.

Thanks.


Yes there is a way but you must not use function import (adding stored procedures to your model doesn't make sense in this case). Use:

var data = objectContext.ExecuteStoreQuery<MyPoco>("spName", SqlParams);

to call you stored procedure.