Entity Framework is an ORM layer for .NET applications. Sometimes, we import data from a flat file. Technically, this boils down to: Delete all records from the table. And insert new records into the table.

Import data

Below is the first cut of code that I wrote. A logical use of Entity framework. But unexpectedly, yields very poor performance.

// delete data
foreach(Employee emp in context.Employees)
Read More

ASP.NET Web API is the framework for creating HTTP services or RESTful services in the Microsoft platform. It super-cedes the WCF framework. Browsers in desktops, tablets or mobiles can access the Web API.

Comment API

In this post, we create a Web API for Comments. Create a new MVC application. Create a controller called CommentController. It is an API controller with CRUD methods and integrates with Entity Framework.…

Read More

Sometimes, a controller action trigger a long running background process. For example, the user clicks a link in the page. Generate a word document in the background. Show the properties of the document in the subsequent page. Generation of word documents take anywhere between 3 seconds to 30 seconds. During this time, the user needs some feedback about the progress of the operation.…

Read More

Consider the following code which has a CheckBox and a submit button:

@using (Html.BeginForm())
{
    <input type="checkbox" name="Select" />
    <input type="submit" value="Submit" />
}

Submit the form. The request body has the form data with name-value pairs. If the user checks the checkbox, the form data has Select=on. If the user clears the checkbox, the form data does not contain Select.…

Read More

Consider a GridView with a checkbox column. We want to select all checkboxes or clear all checkboxes within this column using a Select All checkbox in the header row.

GridView Definition

The GridView has a template column. Template defines the header row as well as the item row. In the header row, we have the Select All checkbox. And within in the item row, we have a checkbox to select an item.…

Read More

A data-tier application (.dacpac) creates or updates database schema for SQL Server. Usually, database administrators deploy the application in SQL Server using Management Studio (SSMS). Sometimes, we have to deploy the application programatically. This post explains how to deploy a data-tier application to SQL Azure using .NET.

While deploying using a program, we use a background task, typically a worker role in Azure.…

Read More