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
  • Privacy Policy

Author: ErcanOPAK

Asp.Net Core / C#

Background Tasks the Right Way

- 29.12.25 - ErcanOPAK comment on Background Tasks the Right Way

The Problem: You are firing off Task.Run() in a controller and hoping it finishes, but the server kills it. The Fix: Implement BackgroundService. It’s the reliable, built-in way to run long-running processes. public class Worker : BackgroundService { protected override async Task ExecuteAsync(CancellationToken stoppingToken) { while (!stoppingToken.IsCancellationRequested) { // Your logic here await Task.Delay(1000, stoppingToken); […]

Read More
Asp.Net Core / C#

Hot Reload Configuration with IOptionsSnapshot

- 29.12.25 - ErcanOPAK comment on Hot Reload Configuration with IOptionsSnapshot

The Problem: You changed a value in appsettings.json, but the app keeps using the old value until you restart the server. The Fix: Inject IOptionsSnapshot<T> instead of IOptions<T>. It reads the config file every time the request is made. public class MyService { private readonly MySettings _settings; // Updates immediately when json changes! public MyService(IOptionsSnapshot<MySettings> […]

Read More
SQL

Parse JSON directly in T-SQL

- 29.12.25 - ErcanOPAK comment on Parse JSON directly in T-SQL

The Problem: You stored a JSON blob in a text column and need to query a specific property without writing a backend script. The Fix: Use OPENJSON or JSON_VALUE (SQL Server 2016+). — Extract specific property from JSON column SELECT JSON_VALUE(SettingsColumn, ‘$.theme’) AS UserTheme FROM UserPreferences WHERE JSON_VALUE(SettingsColumn, ‘$.isActive’) = ‘true’;  

Read More
SQL

Finding Duplicates Instantly in SQL

- 29.12.25 - ErcanOPAK comment on Finding Duplicates Instantly in SQL

The Problem: You have duplicate rows in a table and you need to identify them immediately. The Fix: Use GROUP BY and HAVING to isolate records appearing more than once. SELECT Email, COUNT(*) as Count FROM Users GROUP BY Email HAVING COUNT(*) > 1;  

Read More
C#

Splitting Lists with .Chunk()

- 29.12.25 - ErcanOPAK comment on Splitting Lists with .Chunk()

The Problem: You need to process a list of 10,000 items in batches of 100, but writing the for loop math is tedious and error-prone. The Fix: Since .NET 6, you can simply use LINQ’s .Chunk(). var heavyItems = GetHugeList(); // Instantly splits into arrays of 100 items foreach (var batch in heavyItems.Chunk(100)) { ProcessBatch(batch); […]

Read More
C#

Stop Allocating Memory with Span

- 29.12.25 - ErcanOPAK comment on Stop Allocating Memory with Span

The Problem: You need to parse a large string (like a substring), but String.Substring() creates a new string object in memory every time, hurting performance. The Fix: Use Span<T>. It provides a type-safe, memory-safe representation of a contiguous region of arbitrary memory without allocation. string text = “2023-10-25”; // Instead of text.Substring(0, 4) which allocates… […]

Read More
C#

The Null Coalescing Assignment Operator (??=)

- 29.12.25 | 29.12.25 - ErcanOPAK comment on The Null Coalescing Assignment Operator (??=)

The Problem: You are writing verbose if (variable == null) checks just to assign a default value. The Fix: Use ??= to assign a variable only if it is currently null. It makes your initialization logic incredibly clean. // Old way if (myList == null) { myList = new List<string>(); } // Life-saver way myList […]

Read More
Visual Studio

Visual Studio — “Build Succeeded” but App Uses Old DLLs

- 28.12.25 - ErcanOPAK comment on Visual Studio — “Build Succeeded” but App Uses Old DLLs

🧠 Cause Incremental build cache mismatch. ✅ Fix Clean + Rebuild entire solution.

Read More
Wordpress

WordPress — Revisions Table Can Explode Database Size

- 28.12.25 - ErcanOPAK comment on WordPress — Revisions Table Can Explode Database Size

Every save creates a revision. ✅ Fix Limit revisions in wp-config.php.

Read More
Windows

Windows 11 — Virtualization Eats RAM Silently

- 28.12.25 - ErcanOPAK comment on Windows 11 — Virtualization Eats RAM Silently

Hyper-V / WSL reserves memory. ✅ Tip Limit VM memory explicitly.

Read More
Windows

Windows 11 — Game Mode Can Hurt Dev Performance

- 28.12.25 | 28.12.25 - ErcanOPAK comment on Windows 11 — Game Mode Can Hurt Dev Performance

Optimizes GPU, throttles background tasks. ✅ Fix Disable Game Mode for dev machines.

Read More
Ajax / JavaScript

AJAX — Missing credentials Breaks Auth Cookies

- 28.12.25 - ErcanOPAK comment on AJAX — Missing credentials Breaks Auth Cookies

fetch(url) ❌ Problem Cookies not sent. ✅ Fix credentials: “include”    

Read More
JavaScript

JavaScript — setInterval Drifts Over Time

- 28.12.25 - ErcanOPAK comment on JavaScript — setInterval Drifts Over Time

Intervals accumulate delay. ❌ Result Timers become inaccurate. ✅ Fix Use recursive setTimeout.

Read More
HTML

HTML5 — Without width/height Causes Layout Shift

- 28.12.25 - ErcanOPAK comment on HTML5 — Without width/height Causes Layout Shift

CLS hurts SEO and UX. ✅ Fix Always specify dimensions.

Read More
CSS

CSS — display: none Skips Layout but Breaks Animations

- 28.12.25 - ErcanOPAK comment on CSS — display: none Skips Layout but Breaks Animations

Hidden elements cannot animate. ✅ Alternative Use: visibility: hidden;  

Read More
Asp.Net Core

.NET Core — UseDeveloperExceptionPage in Production Is Dangerous

- 28.12.25 - ErcanOPAK comment on .NET Core — UseDeveloperExceptionPage in Production Is Dangerous

Leaks: stack traces internal paths config values ✅ Rule Enable only in Development.

Read More
Asp.Net Core

.NET Core — Model Validation Runs Before Your Code

- 28.12.25 - ErcanOPAK comment on .NET Core — Model Validation Runs Before Your Code

Even before controller logic. 🧠 Why it matters Expensive validations slow APIs Happens on every request ✅ Tip Keep DTOs small and flat.

Read More
SQL

SQL — DELETE Without Batching Locks Tables

- 28.12.25 - ErcanOPAK comment on SQL — DELETE Without Batching Locks Tables

Large deletes = blocking. ✅ Safe pattern DELETE TOP (1000) FROM Logs Loop until rows = 0.

Read More
SQL

SQL — OR Conditions Can Disable Indexes

- 28.12.25 - ErcanOPAK comment on SQL — OR Conditions Can Disable Indexes

WHERE Status = 1 OR Status = 2 ❌ Effect Index seek → index scan. ✅ Fix Rewrite with IN or UNION.

Read More
C#

C# — using Blocks Can Hide IO Bottlenecks

- 28.12.25 - ErcanOPAK comment on C# — using Blocks Can Hide IO Bottlenecks

using var stream = File.OpenRead(path); 🧠 Problem Dispose can block while flushing buffers. ✅ Rule Avoid heavy IO inside tight loops.

Read More
C#

C# — string.Concat Is Faster Than string.Format

- 28.12.25 - ErcanOPAK comment on C# — string.Concat Is Faster Than string.Format

Formatting is expensive. ✅ Faster var s = string.Concat(a, “-“, b); ❌ Slower string.Format(“{0}-{1}”, a, b); Impact: hot paths, logging, serialization.  

Read More
C#

C# — readonly Fields Don’t Make Objects Immutable

- 28.12.25 - ErcanOPAK comment on C# — readonly Fields Don’t Make Objects Immutable

Many devs assume readonly = immutable. ❌ Reality readonly protects the reference, not the object. readonly List<int> items = new(); items.Add(1); // allowed ✅ Fix Use immutable collections when needed.

Read More
Asp.Net Core

Performance — Measuring in Dev Lies to You

- 28.12.25 - ErcanOPAK comment on Performance — Measuring in Dev Lies to You

Local machines hide: IO waits CPU contention GC pressure ✅ Rule Benchmark under production-like load.

Read More
C#

Observability — Logs Without Correlation IDs Are Noise

- 28.12.25 - ErcanOPAK comment on Observability — Logs Without Correlation IDs Are Noise

Distributed tracing without IDs is guesswork. ✅ Fix Propagate correlation IDs across services.

Read More
Kubernetes

Kubernetes — Liveness Probes Can Kill Healthy Pods

- 28.12.25 | 29.12.25 - ErcanOPAK comment on Kubernetes — Liveness Probes Can Kill Healthy Pods

Aggressive probes restart working services. ✅ Rule Liveness = is it stuck? Readiness = can it receive traffic?

Read More
Docker

Docker — Layer Order Can Double Image Size

- 28.12.25 | 29.12.25 - ErcanOPAK comment on Docker — Layer Order Can Double Image Size

Bad order: COPY . . RUN npm install ✅ Fix Copy manifests first, install, then source.

Read More
Git

Git — Line Endings Break Builds Cross-Platform

- 28.12.25 - ErcanOPAK comment on Git — Line Endings Break Builds Cross-Platform

CRLF vs LF causes: failing tests weird diffs ✅ Fix Use .gitattributes.

Read More
C#

JSON — Schema Validation Prevents Silent API Breakage

- 28.12.25 - ErcanOPAK comment on JSON — Schema Validation Prevents Silent API Breakage

Clients change. APIs break quietly. ✅ Fix Validate JSON against schema before processing.

Read More
C#

Cancellation — Passing Token Is Not Enough

- 28.12.25 - ErcanOPAK comment on Cancellation — Passing Token Is Not Enough

You passed CancellationToken…but didn’t observe it. ✅ Rule Check ThrowIfCancellationRequested() in loops.

Read More
C#

Async Streams — IAsyncEnumerable Saves Memory

- 28.12.25 - ErcanOPAK comment on Async Streams — IAsyncEnumerable Saves Memory

Instead of loading everything: await foreach (var item in stream) Benefits Lower memory usage Faster first response Ideal for large datasets

Read More
Page 50 of 69
« Previous 1 … 45 46 47 48 49 50 51 52 53 54 55 … 69 Next »

Posts navigation

Older posts
Newer posts
April 2026
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
27282930  
« Mar    

Most Viewed Posts

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

Recent Posts

  • C#: Use Init-Only Setters for Immutable Objects After Construction
  • C#: Use Expression-Bodied Members for Concise Single-Line Methods
  • C#: Enable Nullable Reference Types to Eliminate Null Reference Exceptions
  • C#: Use Record Types for Immutable Data Objects
  • SQL: Use CTEs for Readable Complex Queries
  • SQL: Use Window Functions for Advanced Analytical Queries
  • .NET Core: Use Background Services for Long-Running Tasks
  • .NET Core: Use Minimal APIs for Lightweight HTTP Services
  • Git: Use Cherry-Pick to Apply Specific Commits Across Branches
  • Git: Use Interactive Rebase to Clean Up Commit History Before Merge

Most Viewed Posts

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

Recent Posts

  • C#: Use Init-Only Setters for Immutable Objects After Construction
  • C#: Use Expression-Bodied Members for Concise Single-Line Methods
  • C#: Enable Nullable Reference Types to Eliminate Null Reference Exceptions
  • C#: Use Record Types for Immutable Data Objects
  • SQL: Use CTEs for Readable Complex Queries

Social

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