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

Day: December 5, 2025

SQL

The Secret Weapon: APPLY β€” Why CROSS APPLY Beats Subqueries

- 05.12.25 - ErcanOPAK comment on The Secret Weapon: APPLY β€” Why CROSS APPLY Beats Subqueries

CROSS APPLY is the Ferrari of SQL join techniques.It looks fancy, and it really is. 🏎️ ⚑ Why CROSS APPLY Is Amazing 🧠 Lets you join custom row-by-row logic πŸš€ Runs faster than correlated subqueries πŸ” Works great with TOP, aggregates & ranking πŸͺ„ Cleaner than temp tables SELECT u.Id, x.LastOrder FROM Users u CROSS […]

Read More
SQL

Indexing Superpowers: The 5 Index Types Every Dev Should Know

- 05.12.25 - ErcanOPAK comment on Indexing Superpowers: The 5 Index Types Every Dev Should Know

Indexes aren’t magic —…but they often look like magic when your query goes 40 sec β†’ 20 ms. ⚑ πŸ† 5 Index Types Everyone Should Know πŸ”Ή Clustered Index β€” defines table order πŸ”Ή Nonclustered Index β€” fast lookup πŸ”Ή Include Columns β€” covering index booster πŸ”Ή Filtered Index β€” tiny but powerful πŸ”Ή Columnstore […]

Read More
SQL

Parameter Sniffing β€” The #1 SQL Server Mystery You Must Understand

- 05.12.25 | 05.12.25 - ErcanOPAK comment on Parameter Sniffing β€” The #1 SQL Server Mystery You Must Understand

Parameter sniffing is NOT a bug.It’s SQL Server being too smart… sometimes. 😈 The Problem SQL caches a plan for one parameter and reuses it: EXEC GetOrdersByCustomer @customerId = 1; — cached plan EXEC GetOrdersByCustomer @customerId = 9999; — wrong plan reused ⚠ Symptoms Extreme slowdowns Terrible cardinality estimates β€œIt’s fast for me but slow […]

Read More
SQL

Never Use SELECT * in Production β€” Here’s Why It Destroys Performance

- 05.12.25 - ErcanOPAK comment on Never Use SELECT * in Production β€” Here’s Why It Destroys Performance

SELECT * feels convenient……but costs you RAM, CPU, network IO, and index usage. ❌ Why SELECT * Is Dangerous 🧱 Prevents covering index usage 🚚 Sends unnecessary columns over network πŸ”„ Breaks when columns change 🐒 Slows down joins & scans — ❌ Bad SELECT * FROM Orders; — βœ” Good SELECT Id, OrderDate, Amount […]

Read More
SQL

The Hidden Killer: Scalar Functions β€” How to Avoid Massive Slowdowns

- 05.12.25 - ErcanOPAK comment on The Hidden Killer: Scalar Functions β€” How to Avoid Massive Slowdowns

Scalar functions look innocent……until your query goes from 50 ms β†’ 12 seconds. — ❌ Never do this inside SELECT SELECT Id, dbo.GetUserScore(Id) FROM Users; πŸ’₯ Why They’re Slow β›“ Executed row-by-row 🚫 Breaks parallelism πŸ“‰ Kills execution plans 🐌 Turns queries into RBAR (β€œRow By Agonizing Row”) βœ” The Fix Use Inline Table-Valued Functions […]

Read More
Asp.Net Core / C#

Clean Dependency Injection β€” Lifetimes That Every Dev Must Master

- 05.12.25 - ErcanOPAK comment on Clean Dependency Injection β€” Lifetimes That Every Dev Must Master

⏳ The 3 Lifetimes πŸ”΅ Singleton β†’ stateless global services 🟒 Scoped β†’ per-request (web default) 🟠 Transient β†’ lightweight, multi-instance ❌ Absolute Rule Never inject a Scoped service into a Singleton. Bad: builder.Services.AddSingleton<MyService>(); // depends on DbContext ❌ βœ” Correct Use factory: builder.Services.AddSingleton<MyService>(sp => new MyService(sp.GetRequiredService<IDbContextFactory<AppDb>>())); 🧠 Why? Prevents stale data Eliminates threading issues […]

Read More
Asp.Net Core / C#

EF Core: ExecuteUpdate & ExecuteDelete β€” Why You Should Stop Looping

- 05.12.25 | 05.12.25 - ErcanOPAK comment on EF Core: ExecuteUpdate & ExecuteDelete β€” Why You Should Stop Looping

The old way: foreach (var user in users) user.IsActive = false; await ctx.SaveChangesAsync(); The modern way: await ctx.Users.Where(x => x.IsActive) .ExecuteUpdateAsync(set => set.SetProperty(p => p.IsActive, false)); ⚑ Benefits πŸš€ Single SQL statement 🧼 No tracking overhead πŸ’Ύ Saves CPU + DB roundtrips 🧩 Perfect for batch jobs + cron workers

Read More
Asp.Net Core / C#

C# Records β€” Why They Still Beat Classes for Domain Models

- 05.12.25 | 05.12.25 - ErcanOPAK comment on C# Records β€” Why They Still Beat Classes for Domain Models

Records are still the cleanest way to model immutable domain data. public record Order(int Id, decimal Total, string Status); ❀️ Why Devs Love Records πŸ” Built-in immutability πŸ“ Value-based equality βœ‚ Boilerplate goes to zero πŸ”„ Perfect for event-driven + DDD ⚑ Extra Tip Use with expressions to clone deeply but safely.

Read More
Asp.Net Core / C#

.NET 9 Rate Limiting β€” Easy API Protection

- 05.12.25 | 05.12.25 - ErcanOPAK comment on .NET 9 Rate Limiting β€” Easy API Protection

Rate limiting used to be hard… now it’s literally one line. app.UseRateLimiter(new() { GlobalLimiter = PartitionedRateLimiter.CreateChained( PartitionedRateLimiter.CreateFixedWindow(10, TimeSpan.FromSeconds(5)) ) }); πŸ”’ Why You Need It πŸ›‘ Stops brute-force πŸ“‰ Protects API throughput βš™ Cloud-native resilience 🌍 Zero-config distributed support (Redis optional) 🧠 Bonus Pair with Minimal APIs for super-light API services.

Read More
Asp.Net Core / C#

Async Streams in C# β€” Clean, Fast, Real-Time Data

- 05.12.25 | 05.12.25 - ErcanOPAK comment on Async Streams in C# β€” Clean, Fast, Real-Time Data

πŸŒ€ Why Async Streams Shine Async Streams (IAsyncEnumerable<T>) are perfect for streaming data without memory blows. await foreach (var log in service.GetLogsAsync()) { Console.WriteLine(log); } ✨ What They Solve πŸ” Handling live logs πŸ“‘ Streamed API responses 🧡 Reducing memory spikes 🌊 Backpressure-friendly async flow πŸ’‘ Pro Tip Combine with channels for ultra-responsive pipelines.

Read More
December 2025
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
293031  
« Nov   Jan »

Most Viewed Posts

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

Recent Posts

  • C# Value Types Copied More Than You Think
  • C# Async Void Is Dangerous
  • C# Foreach vs For Performance Difference
  • SQL Deletes Lock Tables
  • SQL Queries Slow Despite Indexes
  • .NET Core APIs Feel Slow Under Load
  • ASP.NET Core Memory Grows Slowly
  • Git Conflicts Keep Reappearing
  • Git Rebase Feels Dangerous
  • Ajax Forms Submit Twice

Most Viewed Posts

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

Recent Posts

  • C# Value Types Copied More Than You Think
  • C# Async Void Is Dangerous
  • C# Foreach vs For Performance Difference
  • SQL Deletes Lock Tables
  • SQL Queries Slow Despite Indexes

Social

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