I have a stored procedure in a SQL Server database that returns a list of results. This stored procedure is exposed in the LINQ-to-SQL dbml file. I then try to call this stored procedure as such:
public List<MyObject> GetObjects()
{
List<MyObject> objects = new List<MyObject>();
using (DatabaseDataContext context = new DatabaseDataContext())
{
objects = context.GetObjectsFromDB(); // This is my problem line
}
return objects;
}
My problem is, I don’t know how to convert the results of the stored procedure to a List<MyObject>. context.GetObjectsFromDB returns a System.Data.Linq.ISingleResult<sprocName>. How do I convert the result of the stored procedure to my List of strong pre-defined type?
Thank you!
Try this,
Updated:
By using explicit casting it can be done like this