I’m running a small test on a WCF service, so I’m loading up 1000 accounts, and for each I want to call a method that returns an object. I’m missing something here, as the runAccount method is never called.
private static void RunTest()
{
var accounts = CsvHelper.ParseCsv(@"Data\acccounts.csv");
GeneralHelper.MemberData = (from a in accounts.AsParallel()
select runAccount(a)) as IList<MemberFormDataContract>; //PLINQ
}
private static MemberFormDataContract runAccount(Account acct)
{
IAccountMasterService accountMasterService = new AccountMasterServiceClient();
MemberFormDataContract memberFormDataContract = accountMasterService.FindMemberFormByAccountId(acct.Id);
return memberFormDataContract;
}
the point here is that I want to run the call for each account in the list, and populate a helper class with the results that is timing the calls and looking for high/low and an average. the problem is that the actual call to the service is never made, which helps the number look fantastic, but totally bogus.
Replace
as IList<MemberFormDataContract>byToList(). The execution of yourselectstatement is deferred until you force it to be executed by (e.g.) ToList().