Inserting Null Value for Integer columns in Windows Azure Table

I recommend to read  below post before you start reading this post

Creating Azure Table using CloudTableClient.CreateTableIfNotExist

There may be requirement when you need to insert null values for values type columns in Azure table. In our recent project, we had a requirement to insert null values for integer columns. Usually if you don’t provide any value to Integer variable, it would get initialized as 0, since they are value type’s variables. This post will focus on providing null values for integer columns

Very first you need to define and entity as below,



You may have noticed that I am making integer properties as Nullable types


Now create Azure table as below,


Then you can insert null value for integer columns as below,


For your reference full source code to insert null values is as below,

using System;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.StorageClient;

namespace ConsoleApplication7
class Program
static void Main(string[] args)
CloudStorageAccount account = CloudStorageAccount.Parse("connectionString");
CloudTableClient tableClient = new CloudTableClient(
string tableName = "School";
TableServiceContext  context = tableClient.GetDataServiceContext();
SchoolEntity entity = new SchoolEntity
Age = null,
Name = "DJ",
PartitionKey = "S",
RollNumber  = null ,
RowKey = Guid.NewGuid().ToString()

context.AddObject(tableName, entity);



public class SchoolEntity : TableServiceEntity
public string Name { get; set; }
public int ? RollNumber { get; set; }
public int ? Age { get; set; }



In this way you can insert null values. I hope this post was useful. Thanks for reading Smile

If you find my posts useful you may like to follow me on twitter or may like Facebook page of my blog If you want to see post on a particular topic please do write on FB page or tweet me about that, I would love to help you

2 responses to “Inserting Null Value for Integer columns in Windows Azure Table”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s