-
Store Multiple NULL values with unique data in SQL Server
Hello friends, Sometimes we get the data that needs to be unique but can also get NULL records. Existing ways to achieve uniqueness doesn’t allow NULLs (Primary Key) or allow max one NULL (Unique Constraint). Let’s take an example to understand this better. Suppose, you have an Employee table with fields like Id, FirstName, MiddleName,…
-
Enable CORS in ASP.NET Core Web API
Hello friends, As we know that in Web API, CORS is by default disabled due to security reasons. and hence if a client tries to access API in different server and port, you can end up with error as “Origin http://localhost:xxxx is not allowed by Access-Control-Allow-Origin“ To enable it in ASP.NET Core Web API, there…
-
Working with Prototype Design Pattern
Hello friends, I am resuming series on design patterns. Today we will go through another design pattern called Prototype. It falls under a creational pattern category. Before talking about its implementation let’s begin with defining it. A prototype is a design pattern that believes and enforces object cloning or copying over new object creation. But…
-
Working with Facade Software Design Pattern
Hello friends, Hope you are doing well. Today we will be looking into another software design pattern called Facade. Before talking about its implementation, let’s begin by defining it. As per GOF guys, Facade pattern is defined as: “Provide a unified interface to a set of interfaces in a subsystem. Façade defines a higher-level interface…
-
Working with Bridge Software Design Pattern
Hello friends, I am here to go though one of the useful design pattern called Bridge. Before talking about its implementation let’s begin with defining it. As per GOF guys, Bridge Pattern is defined as follows. “Decouple an abstraction from its implementation so that the two can vary independently.” Well! Let’s understand what they mean…
-
Working with Builder Software Design Pattern
Hello friends, Hope you are doing great. Today Lets go through another software design pattern called Builder. Before talking about its implementation let’s begin with defining it. As per GOF, Builder pattern is defined as following. “Separate the construction of a complex object from its representation so that the same construction process can create different…
-
String and StringBuilder in Design and Action
Hello Friends, Lets have a look at old yet relevant point about String and String Builder. Both constructs are meant to manipulate the strings but in their own way. A string (namespace: System.String ) is a sequential collection of Unicode characters that represent text. A String object is immutable (read-only) and a sequential collection of…
-
Working with Abstract Factory Pattern
Hello friends. Today I am here to go though another variant of Factory design pattern called Abstract Factory. In case, you have not had a look at my previous article about Factory pattern, I would suggest you to look for them in ARCHIVES section. Before talking about its implementation let’s try to understand the purpose…
-
var keyword constraints as class fields in C#
Hello friends. Hope you are doing well!! Wish you happy new year!! I am here to talk about the var keyword constraint, when using it in the class level fields in C#. Sometimes , we get a question that why can’t we use var keyword in initializing the class level fields. Let’s have a look at…
-
Enforcing date pattern with DateTime.TryParseExact method
Hello friends, Today we will go though a useful method of datetime class called TryParseExact. You can use this method to specify the pattern in which you want user to enter the dates. There are two overloads as following. TryParseExact(String, String, IFormatProvider, DateTimeStyles, DateTime)TryParseExact(String, String[], IFormatProvider, DateTimeStyles, DateTime) Example: var isValid = DateTime.TryParseExact(Convert.ToString(value), “d MMM yyyy”,…
