StackOverlord
StackOverlord

Reputation: 85

typing LINQ Queries in Controller max CPU usage 100%

Hi I got this very strange problem I have a reports controller that is full of LINQ queries about 8k Lines of code I notice this when I was typing the codes in the 7k+ range. I check the resource monitor it shows 100% cpu usage in one of the cores.

I have Intel core i5 3rd gen, 16gb RAM, 7600rpm HDD,

Upvotes: 0

Views: 624

Answers (1)

Andreas
Andreas

Reputation: 1081

Having 8k lines of code in a constructor, or simply just in a file is bad design. A constructor should generally be initializing, not do heavy work. Put this in a method, and then a method should never be longer than it can fit entirely on a small screen (15-20 lines max). So you should definitely refactor your code. Especially watch out for long lines, as VS handles these badly - and by long lines I mean longer than 1k chars. Even though screens today can show much, much more code than 20 lines, you will find that this approach makes your code much more readable.

Upvotes: 3

Related Questions