I have the following:
using (var dsProperties = GetDataset(SP_GET_APPLES, arrParams))
{
var apples= dsProperties.Tables[0].AsEnumerable()
.Select(r => new Apple()
{
Color = r[0].ToString(),
Year = r[1].ToString(),
Brand= r[2].ToString()
});
return apples.ToList();
}
Now, I would like to have an extension method on Dataset to which I can pass the needed Type as a parameter and get the intended List back… something like
dsProperties.GetList(Apple);
which can also be used for
using (var dsProperties = GetDataset(SP_GET_ORANGES, arrParams)){
dsProperties.GetList(Orange); }
Is there a way to accomplish this?
How about this?
And usage:
This mapping can well be put in another place as well.