My program has the following class definition:
public sealed class Subscriber
{
private subscription;
public Subscriber(int id)
{
using (DataContext dc = new DataContext())
{
this.subscription = dc._GetSubscription(id).SingleOrDefault();
}
}
}
,where
_GetSubscription()
is a sproc which returns a value of type ISingleResult<_GetSubscriptionResult>
Say, I have a list of type List<int>
full of 1000 id
s and I want to create a collection of subscribers of type List<Subscriber>
.
How can I do that without calling the constructor in a loop for 1000 times?
Since I am trying to avoid switching the DataContext on/off so frequently that may stress the database.
TIA.