Posts

Showing posts from May, 2023

Synchronous or Asynchronous Programming in C#

Both are programming techniques with some pros and cons, let's see in details Synchronous : - It works in single thread Doesn't help in responsive UI Best for quick and simple tasks - It blocks the main thread and UI Cancellation token not supported - It throws the exception immediately but async keeps them in Task Asynchronous : Support cancellation tokens To use it we need async/await keyword - It is UI friendly and can be multi-threaded Use them for handling multiple requests concurrently Putting await in our code doesn't block the main thread Use asynchronous programming for lengthy 1/0 operations By using the await we can wait until the results are computed

15+ .NET Libraries you should Know

15+ .NET Libraries you should Know : Now a days libraries play an important role in your development, start learning these libraries for a good development experience 1.Mediator for CQRS 2.Dapper for micro-ORM 3.Serilog and NLog for logging 4.Bogus for fake data generation 5.Fluent Validation for validations 6.SignalR for real time communication 7.Moq for mock interfaces and classes 8.Hangfire and Quartz for background jobs 9.Noda Time best in the town for date-time 10.Autofac for Dependency Injection Container 11.MiniProfiler for profiling your application 12.Automapper, Mapster and Mapperley for Mappings 13.Polly for fault handling (Retry, Circuit Break) 14.NewtonSoft JSON for playing with JSON and Objects 15.BenchmarkDotNet helpful in measuring the performance 16.Swagger for better API experience (built in.NET Core)

Why Store Procedures are faster than LINO Query?

Why Store Procedures are faster than LINO Query? SPs are faster from LINQ because they have pre compiled execution plan, so after first time cached executed plan is used which created impacts. SP(s): It's difficult to debug them Procedure run on server side For complex queries itis best ⁃ It consumes database resources For deployment we have to provide scripts SP can't perform best if you are not good at writing optimized queries, be careful LINQ: It is compiled each and every time ⁃ It is not suitable for complex queries - LINQ is type safe and easy to debug You should know how to write better LINQ queries for better performance - LINQ isn't good for bulk operations, although n.NET 7 we have got the bulk operations, let's see if they can perform better than SP(s)