Farhad-Taran
Farhad-Taran

Reputation: 6540

how to structure code to run the same service for multiple objects?

I have a number of instances of the following object:

public class Brief{
   public int ID {get; set;}
   public DateTime StartDate {get; set;}
   public DateTime EndDate {get; set;}
} 

I want to run the same console service for all these instances. the service essentially uses the ID property and the dates property to search in a database and return the related records for that particular Bried ID.

my question is what is the best approach to structure my code.

should I create a single class with a List and do a foreach on that list and run the appropriate method or should I create a different instance for each of the objects and then run the services.

Upvotes: 3

Views: 74

Answers (1)

ganders
ganders

Reputation: 7451

I'd go with List. Iterate over each one and fire off the method to do your search in a separate thread. That way all 3 searches are performing at the same time.

Upvotes: 1

Related Questions