2

In queries to XRM, is it helps to use the parallel extension library as so

xrm.AccountSet.AsParallel().Where(v=>v.ModifiedBy == DateTime.Now).FirstOrDefault()

Instead of

xrm.AccountSet.Where(v=>v.ModifiedBy == DateTime.Now).FirstOrDefault()

Or there is no difference?

Thanks

Yacov
  • 1,060
  • 14
  • 27

2 Answers2

2

I'm not sure exactly how the XRM library converts LINQ to the Query Expressions but the Query Expressions have no concept of as parallel(). So I would guess that xrm.AccountSet.AsParallel() would have worse performance than xrm.AccountSet.FirstOrDefault().

But in an effort to teach a man to fish rather than giving him one, read Eric Lippert's answer Which is faster?.

Daryl
  • 18,592
  • 9
  • 78
  • 145
0

You must use AsParallel() after AccountSet.

For concrete example use

xrm.AccountSet.FirstOrDefault(v=>v.ModifiedBy == DateTime.Now);
Hamlet Hakobyan
  • 32,965
  • 6
  • 52
  • 68