I have a stored procedure that returns a list. Now I’m trying to write a function that will pass the stored procedure that correct parameter and then return the list so that it can be used on asp web page. I’m completely lost.
I’ve tried this so far to no avail
public static List<RetrieveActiveMuseumByMuseumID_Result> GetActiveMuseum()
{
using (MuseumDB db = new MuseumDB(ConfigurationManager.ConnectionStrings["MuseumDB"].ConnectionString))
{
List<RetrieveActiveMuseumByMuseumID_Result> listOrdered = new List<RetrieveActiveRigsWithEquipmentByOffice_Result>();
}
return listOrdered;
}
But that doesn’t do anything and it doesn’t pass the parameter of the SP which is @MuseumID
Help please I don’t know where to go from here.
For Asp.net data sources: List == bad, Enumerable == good. Both can be used as a data source, but enumerables tend to perform better, especially for asp.net where memory use is so important. Lists force you to have the entire result set in memory. Play your cards right with an enumerable, and you may only need one record in memory at a time.
To make this work, your
RetrieveActiveMuseumByMuseumID_Resulttype needs a staticCreate()method that accepts anIDataRecordand return a newRetrieveActiveMuseumByMuseumID_Resultobject (this follows the Factory pattern).I tend to abstract this pattern away to a “mini-ORM”, using a generic method that looks like this:
And then I would call that for your query like this: