Friday, 19 December 2025
Wednesday, 17 December 2025
when you order by two columns use this.imp
SELECT *
FROM dbo.tbl_WorkFlowMembers w
WHERE w.WorkFlow_ID IN (
SELECT WorkFlow_ID
FROM dbo.tbl_WorkFlow
WHERE country_code = 'BE'
)
ORDER BY
w.WorkFlow_ID,
w.Approver_Sequence DESC;
Sunday, 14 December 2025
kAFKA CONFLUENT FREE TRAIL
For me two promos are showing
VFREETRIAL400 $400.00 / $400.00 USD remaining Expires Jan. 13, 2026 CONFLUENTDEV1 $1.00 / $1.00 USD remaining Expires Jan. 13, 2026For me two promos are showing FREETRIAL400 $400.00 / $400.00 USD remaining Expires Jan. 13, 2026 CONFLUENTDEV1 $1.00 / $1.00 USD remaining Expires Jan. 13, 2026Thursday, 11 December 2025
Sunday, 7 December 2025
Wednesday, 3 December 2025
create delete cascade
if you delete dependant record then child data also deleted
ALTER TABLE tbl_UARRecord
ADD CONSTRAINT FK_tbl_UARRecord_tbl_UploadCycle
FOREIGN KEY (UploadCycleId)
REFERENCES tbl_UploadCycle(UploadCycleId)
ON DELETE CASCADE;
Tuesday, 2 December 2025
DI error
👉 When your ExceptionHandlingMiddleware tries to resolve a scoped service directly from the app root container
(which is NOT allowed).
The fix is simple — and you’re very close.
Let me give you the correct, production-safe version.
✅ Root Cause
Your middleware is registered as a singleton (default), meaning:
-
Middleware = Singleton
-
ErrorLoggerService = Scoped
➡ Middleware cannot directly use scoped service from constructor
➡ Must resolve inside InvokeAsync() using context.RequestServices
You already attempted this — but the middleware itself still injects the service incorrectly.
✅ Correct Fix (100% works)
❌ WRONG (current middleware constructor injects scoped service)
public ExceptionHandlingMiddleware(RequestDelegate next, IErrorLoggerService logger)
This forces the DI system to resolve IErrorLoggerService at startup (root provider).
→ Boom: exception.
✅ ✔ RIGHT: Middleware must NOT receive scoped services in constructor
✔ FIXED Middleware
public class ExceptionHandlingMiddleware
{
private readonly RequestDelegate _next;
private readonly ILogger<ExceptionHandlingMiddleware> _logger;
public ExceptionHandlingMiddleware(RequestDelegate next, ILogger<ExceptionHandlingMiddleware> logger)
{
_next = next;
_logger = logger;
}
public async Task InvokeAsync(HttpContext context)
{
try
{
await _next(context);
}
catch (Exception ex)
{
// 🔥 Resolve scoped service CORRECTLY
var errorLogger = context.RequestServices.GetRequiredService<IErrorLoggerService>();
await errorLogger.LogErrorAsync(new ErrorLogDto
{
UserName = context.User?.Identity?.Name ?? "SYSTEM",
Path = context.Request.Path,
ErrorMessage = ex.Message
}, ex);
await HandleExceptionAsync(context, ex);
}
}
}
Notice:
✔ No scoped services in constructor
✔ Scoped service resolved inside request pipeline → valid
🛠Program.cs validation (your DI is correct)
services.AddScoped<IErrorLoggerService, ErrorLoggerService>();
This is perfect.
No need to change DI.
DI error
🔥 Why This Happens
You likely did ONE of these:
-
Registered
IErrorLoggerServiceas Scoped, but you're calling it from:-
Middleware constructor
-
A static class
-
A background task
-
Something running outside the HTTP request pipeline
-
Inside
Program.csdirectly during startup
-
OR
-
You forgot to register it in DI.
💯 THE FIX: Register the service + Use it correctly in middleware
✅ 1. Register your IErrorLoggerService properly
In Program.cs or ServiceExtensions:
builder.Services.AddScoped<IErrorLoggerService, ErrorLoggerService>();
✅ 2. DO NOT inject scoped services into middleware constructors
Middleware constructor runs once at startup = singleton scope
Scoped services = per request → mismatch
❌ Bad:
public class ExceptionHandlingMiddleware
{
private readonly IErrorLoggerService _errorLogger; // ❌ scoped injected into singleton
}
This is EXACTLY what triggers your error.
✅ 3. Proper way → Resolve inside InvokeAsync using context.RequestServices
Modify your middleware like this:
public async Task InvokeAsync(HttpContext context)
{
try
{
await _next(context);
}
catch (Exception ex)
{
// Resolve scoped service here
var loggerService = context.RequestServices.GetRequiredService<IErrorLoggerService>();
await loggerService.LogErrorAsync(new ErrorLogDto
{
UserName = context.User?.Identity?.Name ?? "SYSTEM",
ErrorMessage = ex.Message,
ErrorProcedure = context.Request.Path,
ErrorDateTime = DateTime.UtcNow
});
throw; // continue normal exception behavior
}
}
This is safe because middleware resolves the scoped service per request.
🎉 This removes the error completely.
⭐ Bonus: Template for IErrorLoggerService
public interface IErrorLoggerService
{
Task LogErrorAsync(ErrorLogDto dto);
}
Implementation:
public class ErrorLoggerService : IErrorLoggerService
{
private readonly UARDbContext _context;
public ErrorLoggerService(UARDbContext context)
{
_context = context;
}
public async Task LogErrorAsync(ErrorLogDto dto)
{
var error = new TblErrors
{
UserName = dto.UserName,
ErrorMessage = dto.ErrorMessage,
ErrorProcedure = dto.ErrorProcedure,
ErrorDateTime = DateTime.UtcNow
};
await _context.TblErrors.AddAsync(error);
await _context.SaveChangesAsync();
}
}
Di errors
Cannot resolve scoped service 'Enviri.UAR.API.Services.IErrorLoggerService' from root provider.'
Monday, 1 December 2025
Capgemini Interview
capgemini famous interview question List<int> A = new List<int>(); A.add(1); List<int> B=A; B=new List<int>(); B.Ad...
-
D:\A-MyProjects2024-2025\ReactNative2025\BookRental\android\app\build\outputs\apk\debug path of apk To build an Android app using Capacitor...
-
OLX, like many large-scale online platforms, employs a variety of data structures and technologies to manage its data effectively. While s...