LINQ/PLINQ AsNoTracking / AsParallel Performance - Usage

217 Views Asked by At

I've read that if you only need to read entities (not to update them) it is better to use AsNoTracking().

As for AsParallel() some dude said it's always better to measure (e.g. Stopwatch) and to decide whether to use it or not.

Now I am going through my code to decide where to use these for a better performance.

my question is... am I getting too far? I ended up using them almost everywhere, even on simple stuff like:

ctx.SomeTable.AsNoTracking().AsParallel().FirstOrDefault(x => x.Id == 3)

or

(from x in ctx.SomeTable select 
    new SomeClass ()
        {
         // .....
}).AsNoTracking().Take(() => 20).AsParallel().ToList()

Am I going too far? What are the best practices regarding AsNoTracking / AsParallel?

0

There are 0 best solutions below