1.
Schedule and Reschedule Message
2. While Process=>
When building a sidebar in Angular, you might want to highlight a parent link when any of its child routes are active. Angular’s routerLinkActive only works for single routes — so here’s a quick 2-step solution using a custom directive.
active class if any match.
✅ Works with multiple child links, query parameters, and is easy to reuse.
✅ This blog is written by TechJourney with Gagan, sharing practical Angular tips for developers.
In modern .NET applications, maintaining clean architecture is critical — and that’s where the Mediator pattern shines. It decouples the request/response flow and promotes separation of concerns.
While libraries like MediatR are popular, sometimes you want something even lighter — with zero dependencies.
Enter: GMediator, a custom lightweight mediator implementation.
When building Angular apps, you might have common logic or reusable layouts across components.
Instead of duplicating code, you can use extends in TypeScript and
ng-template + ngTemplateOutlet in HTML.
Let’s walk through a simple example with 2 components where one extends logic and also injects custom HTML.
This is the reusable component that contains a common layout and logic.
contentTemplate.This component inherits logic from ChildComponent and injects its own template content.
title and getTitle() from ChildComponent.ng-template.Use Cases: shared card layouts, reusable modal structures, dashboards, etc.
#Clone Database
Need to duplicate a full SQL Server database — including tables, views, stored procedures and data — without writing complex scripts?
Let me show you a simple, reliable method: Exporting and Importing a Data-tier Application (.bacpac). It’s perfect for backups, migrations, and creating dev/test clones.
Open SQL Server Management Studio (SSMS).
Right-click your source database → Tasks → Export Data-tier Application.
Choose "Save to local disk", then pick a file path and name (YourDatabase.bacpac).
Click Next through the wizard and generate the .bacpac file.
In SSMS, right-click Databases → Import Data-tier Application.
Select the .bacpac file you exported.
Give the new database a name.
Complete the wizard. ๐ Done!
[ Source DB ]
|
| Export as .bacpac
↓
[ YourFile.bacpac ]
|
| Import on Target Server
↓
[ New DB Clone ]
Why Use This?
๐ Migrate databases between environments (dev, staging, prod).
๐ ️ Create dev/test clones without risking production.
๐ฆ Archive snapshots with both schema and data.
First download and install ollama By this blog:
Tech Journey With Gagan: Run Any AI Model with ollama in windows
Steps for install Any model with ollama in local :
1. Download Olama and install
Note :Later on same command run your model will run automatically this time it is not downloading it just run
In modern C# applications, clean architecture plays a crucial role in maintaining scalability and maintainability. In this blog, we will build a C# Web API using Onion Architecture, CQRS, MediatR, and Quartz.NET for scheduling background jobs. This guide will walk you through structuring a project with best practices and SOLID principles.
Onion Architecture provides a clear separation of concerns by organizing the application into different layers:
Domain Layer → Contains core business logic and entities
Application Layer → Contains CQRS commands, queries, and interfaces
Infrastructure Layer → Handles database, repository pattern, and external integrations
Presentation Layer (API Layer) → Exposes the application as an API
ASP.NET Core Web API for building RESTful APIs
Entity Framework Core for database operations
CQRS Pattern for separating read & write operations
MediatR for in-memory messaging
Quartz.NET for CRON Job scheduling
SOLID Principles to make the application scalable
Your project will be structured as follows:
๐ Location:
Onion.Domain/Models/Student.cs
๐ Location:
Onion.Application/Features/Students/Commands/CreateStudentCommand.cs
๐ Location:
Onion.Application/Features/Students/Queries/GetAllStudentsQuery.cs
๐ Location:
Onion.Infrastructure/Repositories/StudentRepository.cs
๐ Location:
Onion.Infrastructure/Scheduler/CronJobService.cs
Program.cs (API Layer)
๐ Location: Onion.API/Program.cs
By following this guide, you have successfully built a
C# Web API with Onion Architecture,
CQRS, MediatR, and
Quartz.NET CRON Jobs.
This approach ensures:
✅Scalability using Onion Architecture
✅Separation of Concerns (SoC)
✅Background Job Execution with Quartz.NET
✅Better Maintainability with CQRS & MediatR
In modern web applications, performance is key. Fetching data repeatedly from a database can lead to increased response times and higher server load. One effective way to optimize performance is by using in-memory caching to store frequently accessed data. In this blog, we will explore how to integrate IMemoryCache in an ASP.NET Core Web API project to efficiently handle CRUD operations for a Student entity.
In-memory caching is a mechanism that temporarily stores frequently accessed data in memory, reducing the need to retrieve it from the database each time. ASP.NET Core provides IMemoryCache, which is a simple, high-performance, and thread-safe cache.
To demonstrate in-memory caching, let’s build an ASP.NET Core Web API with a StudentController that performs CRUD operations using Entity Framework Core.
Ensure you have the necessary NuGet packages installed in your ASP.NET Core project:
A Semaphore is a synchronization primitive used to control access to a shared resource by multiple threads. It works by maintaining a count that represents the number of available slots for accessing the resource. When a thread enters, the count decreases, and when it leaves, the count increases.
SemaphoreSlim is a lightweight, managed implementation of Semaphore, introduced in .NET Framework 4. It provides better performance and is optimized for cases where a semaphore is needed within a single process.
To limit concurrent access to a resource
Example: Controlling access to a database connection pool or an API rate limit.
To prevent race conditions
Example: Ensuring that only a limited number of threads can modify a shared collection at a time.
To manage multi-threaded access in an efficient way
Example: Restricting simultaneous file writes to avoid corruption.
| Feature | Semaphore ๐ข | SemaphoreSlim ๐ |
|---|---|---|
| Scope | Works across multiple processes | Works within a single process |
| Implementation | Uses OS-level (kernel-based) synchronization | Uses user-mode synchronization (managed by .NET) |
| Performance | Slower due to kernel transitions | Faster as it avoids kernel overhead |
| Async Support | ❌ Does not support async/await | ✅ Supports async/await for better responsiveness |
| Use Case | Inter-process synchronization (e.g., shared system resources) | Within-process synchronization (e.g., limiting concurrent API calls, database access) |
| Blocking vs Non-Blocking | Blocks threads while waiting | Uses async wait, avoiding thread blocking |
| Wait Handle Support | ✅ Supports WaitOne(), WaitAll() | ❌ Does not support WaitHandle methods |
✅ Use Semaphore when you need to synchronize across different applications (e.g., OS-wide named semaphores).
✅ Use Semaphore Slim when you need a lightweight, high-performance synchronization within a single process, especially with async/await.
Note: semaphore slim I used in in memory caching for single process so save dB calls and we give users to fast response.
while semaphore is used for allow or control to multiple processes like if we have to run only two than we can control with that
InMemory caching: In Memory Caching in .Net
✅ Application Start: Code and dependencies are loaded into RAM.
✅ CLR Loads Assemblies: JIT compiles and stores DLLs in RAM.
✅ Memory Allocation: Stack (method calls) & Heap (objects, DI, cache).
✅ Caching (Boosts Speed!): Frequently accessed data is stored in RAM.
✅ Handling HTTP Requests: Kestrel/IIS processes requests in memory.
✅ Garbage Collection: Frees up unused objects, optimizing RAM.
✅ (Optional) In-Memory Database: Uses RAM for high-speed transactions.
๐น Complete Process in a Simple Diagram!
+----------------------------------------------------+
| ๐ข APPLICATION START (Loaded in RAM) |
| - Run API: (dotnet run / IIS / Kestrel) |
| - .NET Runtime (CLR) loads code into RAM |
+----------------------------------------------------+
|
v
+----------------------------------------------------+
| ๐ CLR LOADS ASSEMBLIES (Stored in RAM) |
| - JIT (Just-In-Time) compiles code |
| - Dependencies & DLLs loaded into memory (RAM) |
+----------------------------------------------------+
|
v
+----------------------------------------------------+
| ๐พ MEMORY ALLOCATION (RAM Usage) |
| - Stack: Stores method calls, local variables |
| - Heap: Stores objects, services, cache data |
| - DI Container: Manages service lifetimes |
+----------------------------------------------------+
|
v
+----------------------------------------------------+
| ⚡ CACHING (Improves Speed, Uses RAM) |
| - In-Memory Cache (MemoryCache, Singleton) |
| - Distributed Cache (Redis, NCache) (Optional) |
| - Reduces Database Calls, Increases Performance |
+----------------------------------------------------+
|
v
+----------------------------------------------------+
| ๐ HANDLING HTTP REQUESTS |
| - Kestrel/IIS Listens for Requests |
| - Middleware (Auth, Logging, Compression) |
| - Controllers Execute Business Logic |
+----------------------------------------------------+
|
v
+----------------------------------------------------+
| ๐️ GARBAGE COLLECTION (Frees RAM) |
| - Gen 0: Short-lived objects (frequent cleanup) |
| - Gen 1 & 2: Long-lived objects (less cleanup) |
| - Optimizes RAM usage, prevents memory leaks |
+----------------------------------------------------+
|
v
+----------------------------------------------------+
| ๐ข️ (OPTIONAL) IN-MEMORY DATABASE |
| - EF Core In-Memory / SQLite (Stored in RAM) |
| - Fast Reads/Writes, No Disk I/O |
+----------------------------------------------------+
๐ก Why This Matters?
๐น Faster performance with in-memory caching.
๐น Reduced database calls, improving scalability.
๐น Optimized RAM usage via Garbage Collection.
I created Two methods one for schedule and log in db and second method is related to reschedule message. 1. Schedule and Reschedu...