Author Archives: nikhildoomra

About nikhildoomra

I work as a Sr. Software Developer in an MNC and mostly work on Micorsoft Technologies.

SQL | delete a table if it exists

Keeping a note of frequently used script.

IF (EXISTS (SELECT top 1 * FROM sysobjects WHERE xtype = 'U' AND name = 'tmp_TOBEDELETED'))
	--Do Stuff
	drop table dbo.tmp_TOBEDELETED

Hope this might help someone.


C# | Generic Converter

There are times when we need to dynamically convert/parse the object from its string value to its type.

Below is the generic converter code which we can use instead of creating method for each type.

SomeType temp;

var strVal = "StringValueofObject";
var converter = TypeDescriptor.GetConverter(typeof(temp));

temp = (SomeType)converter.ConvertFromString(strVal);

It basically gets the TypeConverter for the specified type and calls its method ConvertFromString. If we want to have similar functionality for our classes then we can create TypeConverters for our own custom classes.

ASP.NET WEB API | TypeConverter and ModelBinders

So its being a while working on WEB API and still it surprises with me everyday with the new way I can extend it. In this article I would like to share TypeConverters and ModelBinders, how they fit into everyday work and how they can make the API access easier for end clients.

Continue reading

C# | Nullables and null-coalescing operator

Nullables are the special value types which can contain their range of values along with null as an additional value.

Nullables are very useful especially when we deal with database or external systems where there is a possibility of empty or null value for an expected value type.

Lets see how nullables can be created and used.

Continue reading

Visual Studio 2017 15.6.7 Update released

Visual Studio 2017 Version 15.6.7 version was released on April 26, 2018 with the below updates:-

    • VS responsiveness for GIT repositories has increased.
    • /debug:fastlink PDBs now uses less heap memory and is more robust now usually for C++ projects.
    • Couple of C++ compiler fixes
    • Now projects of Java can be used till version JDK 8, Update 172(JDK version 8u172).

To summarize, this update contains fixes related to GIT repositories, C++ compiler, C++ builds, and support for Java.

For more information, please refer MSDN here.

C# – Custom Attributes

Attributes in C# is a way to declaratively add some metadata to the code which can then used to add some functionality using reflection.

Like in XML or HTML we have attributes to define some piece of functionality similarly in .NET we can add attributes to classes, properties, methods etc. All the places where the attributes can be declared or used can be found in AttributeTargets Enumeration.

So, lets see what are the benefits, some of the default attributes provided by the framework and how can we create our own attributes.

Continue reading