Skip to main content

Posts

Which linq method performs better: .Any() vs .Count() > 0?

Introduction In this modern era of enterprises application, entity framework playing a key role in dealing with the databases. so we need to follow the best practices in each statements of our code to speedup. Sometimes we developers will have multiple options to check the same condition. We must choose the best option else it will cost to us. Let's have this scenario, we need to check whether our collection object is having any elements in LINQ. We can use Any() method or Count()>0, still this is debatable topic in many technical forums. So, I decided to create this article for the developers who is having same thought which I am having. Let's conclude is our way   Approaches Performance checking for Any and Count LINQ Methods is trickiest thing over ICollection<T> and IEnumerable<T> ICollection<T>  Count is better performer than Any Method IEnumerable<T> Any is best option, no availability of Count property Public API To check the performance, I nee

How to resolve “No resources of this type found under this subscription” While call an azure function in Logic App

 Introduction Working with azure logic app is amazing, where it provides us to create our own automated workflows with the help of designer by selecting prebuilt operations. Basically it consists of two kind of built in connectors Triggers Actions In one of my use cases, when I click azure function operation and tried to call azure function, I got this issue "No resource of this type found under this subscription". In this article, I will drive you to fix this issue in Azure Logic App. Built in Azure functions Azure functions are very powerful in serverless computing, we can perform calculations in logic app workflow. It can also compute or format the fields in logic app workflow. Let's try to implement this simple use case in Azure Logic App for better understanding Create Workflow Create your sampleworkflow in azure logic app and you could able to see designer menu to orchestrate your services  Create Http Request Trigger Click Add parameters and select both Method and

How to resolve “Windows Principal functionality is not supported on this platform” in Azure App function

  Introduction I have designed an azure app function to process azure service bus queues and topics. The handlers in azure app function are aimed to process service bus messages into SQL database records through handlers. Whereas app functions are built on top of the code-first approach entity framework core 3.1. whenever I post message to Service bus topics I got “Windows principal functionality is not supported on this platform”. Let me explain you how I resolved this problem in this article Problem SQL Server comes handy with Mixed mode authentication where you can use either windows authentication or SQL Server authentication. I have created azure app function from .NET Core 3.1 and entity framework core 3.1.1 and provided local settings connection string with windows authentication mode. “ Server=myserver;Database=mydatabase;integrated security=true; ” In my case handlers can receive the message and processing it. While comes to saving point in database context it is thr

How to Create Shared Look-up tables for microservices

  Introduction MySQL is well known for Enum data type with some predefined values. If we try to insert or update any custom values, we will get exception. Coming to MSSQL we will not have any equivalent data type for MySQL Enum. In monolithic architecture-based applications, it is fine to have code based Enums inside the applications and store their values in database TINYINT data type fields since we will have business layer as intermediate between presentation layer and database layer. We are in new era of microservice architecture-based applications. It is not good to have Enums inside the code base since single application may have fine grained services and each service will have their own domain layer. In such cases we may need to duplicate the code based Enum inside service which may bring maintenance nightmare. For this problem we will introduce the look-up tables as solution which will act like Enum, and it will have its own key-value pair records. Sample Use Case Let us

Power of the extension methods in ASP.NET Core

 Introduction I just wanna recall my favorite Open Closed Principle (OCP) in solid principles. It says that "Software entities should be open for extension, but closed for modification" .In simple words, any object can be allowed to extend the behavior instead of changing or modifying the behavior. This is the rule thumb for TDD applications that we should follow. The extension methods in .NET Core comes handy to fulfill the needs of adding functionality to the existing class without modifying anything. What happens If we modify existing class? Consider we designed a class for the specific purpose lets say "CALC" which is helpful for us to do ADD, SUB,MUL,DIV and all of its return types are integer. And also consider that we are utilizing this class all over the application whenever Calculation needs and completed the Test Cases. Now If we want our "CALC" class to return decimal instead of integer. This functionality could break all over the application. W

How to resolve ASP.NET core web API 2 mins timeout issue

Introduction We are in the new world of microservices and cross-platform applications which will be supported for multiple platforms and multiple heterogeneous teams can work on the same application. I like ASP.NET Core by the way its groomed to support modern architecture and adhere to the software principles. I am a big fan of dot net and now I become the craziest fan after seeing the sophisticated facility by dot net core to support infrastructure level where we can easily perform vertical and horizontal scaling. It very important design aspect is to keep things simple and short and by the way, RESTFul applications are build and it is a powerful mantra for REST-based application and frameworks. Some times we need to overrule some principles and order to handle some situations. I would like to share my situation of handling HTTP long polling to resolve the ASP.Net core 2 mins issue. What is HTTP Long polling? In the RESTFul term, when a client asks for a query from the serv

Popular posts from this blog

How to resolve ASP.NET core web API 2 mins timeout issue

Introduction We are in the new world of microservices and cross-platform applications which will be supported for multiple platforms and multiple heterogeneous teams can work on the same application. I like ASP.NET Core by the way its groomed to support modern architecture and adhere to the software principles. I am a big fan of dot net and now I become the craziest fan after seeing the sophisticated facility by dot net core to support infrastructure level where we can easily perform vertical and horizontal scaling. It very important design aspect is to keep things simple and short and by the way, RESTFul applications are build and it is a powerful mantra for REST-based application and frameworks. Some times we need to overrule some principles and order to handle some situations. I would like to share my situation of handling HTTP long polling to resolve the ASP.Net core 2 mins issue. What is HTTP Long polling? In the RESTFul term, when a client asks for a query from the serv

How to Resolve ASP.NET Core Key Protection Ring Problem in AWS Lambda

Introduction When it comes to server less web application design using asp.net core razor pages, we definitely need to consider a factor of data protection key management and its lifetime in asp.net core. I developed a site using AWS toolkit of ASP.NET Core Razor Pages. The main advantage of ASP.NET Core is cross-platform from where we can deploy our application in MAC, Linux or windows. I deployed my site initially in IIS Server from which I got the results as expected .but later period I decided to host my site in AWS Lambda in order to meet our client requirement. Strangely, I got unexpected behavior from my site. I just refer the cloud information Lambda Log to identify or pinpoint the case, I got the error Information like “Error Unprotecting the session cookie” from the log. In this article, I tried to explain the root cause of the problem and its solution to overcome such kind of issue. Data Protection in ASP.NET Core This is feature in ASP.NET Core which acts as repl

Which linq method performs better: Where(expression).FirstorDefault() vs .FirstOrDefault(expression)

 Introduction When it comes to LINQ, we always have multiple options to execute the query for the same scenario. Choosing correct one is always challenging aspect and debatable one. In one of our previous articles   Any Vs Count  , we have done performance testing about best LINQ methods over .NET types. In this article, I would like to share about  Where(expression).FirstorDefault() vs .FirstOrDefault(expression) Approaches Performance testing for  Where(expression).FirstorDefault() vs .FirstOrDefault(expression) is very interesting IEnumerable<T> or ICollcetion<T>  .FirstOrDefault(expression) is better than  Where(expression).FirstorDefault() Public API To check the performance, I need some amount of data which should already available. So I decided to choose this  public api . Thanks to publicapis Public API Models Entry class using System ; using System.Collections.Generic ; using System.Text ;   namespace AnyVsCount { public class Entry { pub