Home > Net >  About Linq AsParallel () execute the business logic, only the first data is complete
About Linq AsParallel () execute the business logic, only the first data is complete

Time:11-24

Linq AsParallel () to perform the business logic, only the first data is complete,
To a great god help solve, thank you!
 
ReportReport=orderList. AsParallel (). The Select (item=& gt;
{
//this part to extract all
Var model=new FaultReportReportModel ()
{
OrderNo=item. OrderNo
};
//this part to extract a subset is only the first data is normal, other data are all empty,
Var raultReasons="";
Foreach (var fr in the item. RepairRecords)
{
Foreach (var r in fr. FaultReasons)
{
RaultReasons +=r.N ame + ", ";
}
}
if (! String. IsNullOrWhiteSpace (raultReasons))
Model. FaultReasons=raultReasons. Substring (0, raultReasons. Length - 1);
Return the model;
}). ToList ();

CodePudding user response:

Oh my god, now that heavy, CSDN now no one to play?

CodePudding user response:

Not sure if just list Should be no problem, using this way,

If you remove the AsParallel after consistent?

And since you are linq..

Then your code is not

 
OrderList. Select (d=& gt; New XXXX () {orderno=d.o rderno, respons=string. Join (", ", d=& gt; D.r ecds. Select (x=& gt; X.n ame)}). Tolist ();


Why also cycle...

  •  Tags:  
  • LINQ
  • Related