Centralizing Session Access

Storing and retrieving information from the session state is a common use case in most web applications. For example, user information might be retrieved from the database and then stored in the session upon log in of a user. Following this approach, database calls that retrieve information about a user are reduced (ideally to one call only).

Extension Methods

Extension methods are a way to add functionality (methods) to types that you do not own or that you have no access to. This handy feature was introduced in .NET 3.5.

As an example, consider the following question: in C#, how can you know that an integer is positive? Usually you would do something like this:

Using XML with SQL Server

Sometimes there is a requirement to insert multiple values in the database. This can be done using bulk insert, table-valued functions, through XML, or simply by calling an insert procedure that inserts a single item multiple times. In this post we will be taking a look at how to do multiple inserts using a single query through XML using SQL Server 2008.

Serializing DateTime into JSON

In my current project I ran into the requirement of serializing an object with a DateTime property into Json, specifically through the Json() method of the Controller class. I can't say it serialized pretty well though.