Skip to content

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access

Tag: LINQ Best Practices

C#

LINQ Performance Trap: Why .Any() Is 10,000x Faster Than .Count() > 0

- 01.02.26 - ErcanOPAK comment on LINQ Performance Trap: Why .Any() Is 10,000x Faster Than .Count() > 0

Using .Count() > 0 to check if a collection has items? You’re forcing LINQ to enumerate the entire collection just to answer a yes/no question. The Performance Killer: var users = dbContext.Users.Where(u => u.IsActive); // BAD: Counts ALL active users first if (users.Count() > 0) { Console.WriteLine(“We have active users”); } // Database query generated: […]

Read More
February 2026
M T W T F S S
 1
2345678
9101112131415
16171819202122
232425262728  
« Jan    

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (934)
  • How to add default value for Entity Framework migrations for DateTime and Bool (830)
  • Get the First and Last Word from a String or Sentence in SQL (822)
  • How to select distinct rows in a datatable in C# (799)
  • How to make theater mode the default for Youtube (708)
  • Add Constraint to SQL Table to ensure email contains @ (571)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (552)
  • Average of all values in a column that are not zero in SQL (517)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (473)
  • Find numbers with more than two decimal places in SQL (436)

Recent Posts

  • CSS: Use aspect-ratio Property Instead of Padding Hack
  • Windows 11: Snap Windows into Layouts with One Click
  • Windows 11: Never Lose Clipboard History Again with Built-in Manager
  • AI Prompt: Generate Realistic Test Data for Development
  • AI Prompt: Simplify Legal Documents into Plain English
  • AI Prompt: Turn Meeting Notes into Actionable Task Lists
  • Docker: Use docker compose watch to Auto-Rebuild on File Changes
  • Kubernetes: View Real-Time Pod Logs with Stern Instead of kubectl
  • WordPress: Enable Maintenance Mode Without Plugins Using One Line of Code
  • WordPress: Add Custom Code Without Editing Theme Files Using Code Snippets Plugin

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (934)
  • How to add default value for Entity Framework migrations for DateTime and Bool (830)
  • Get the First and Last Word from a String or Sentence in SQL (822)
  • How to select distinct rows in a datatable in C# (799)
  • How to make theater mode the default for Youtube (708)

Recent Posts

  • CSS: Use aspect-ratio Property Instead of Padding Hack
  • Windows 11: Snap Windows into Layouts with One Click
  • Windows 11: Never Lose Clipboard History Again with Built-in Manager
  • AI Prompt: Generate Realistic Test Data for Development
  • AI Prompt: Simplify Legal Documents into Plain English

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com