Creating an ASP.NET Web API using the Entity Framework Code First approach and the Repository pattern

In this article, we will learn how to create an ASP.NET Web API using the Repository pattern and the Entity Framework code first approach. Essentially you’ll learn how to:

  1. Create a core project which will contain entity and the repository interface;
  2. Create an Infrastructure project which will contain database operations code using the Entity Framework code first approach;
  3. Create a Web API to perform CRUD operations on the entity;
  4. Consume the Web API in a jQuery application and render the data in the Ignite UI Chart.

What is a Repository pattern?

Let us first understand why we need a Repository pattern. If you do not follow a Repository pattern and directly use the data then the following problems may arise-

  • Duplicate code
  • Difficulty implementing any data related logic or policies such that caching
  • Difficulty in unit testing the business logic without having the data access layer
  • Tightly coupled business logic and database access logic

By implementing a repository pattern we can avoid the above problems and get the following advantages:

Business logic can be unit tested without data access logic

  • Database access code can be reused
  • Database access code is centrally managed so easy to implement any database access policies such that caching
  • Easy to implement domain logics
  • Domain entities or business entities are strongly typed with the annotations.

Now that we’ve listed how great they are, let’s go ahead and start implanting a repository pattern in the ASP.NET Web API.

Create the Core project

In the core project you should keep the entities and the repository interfaces. In this example we are going to work with the City entity. So let us create a class City as shown in the listing below:

Read the full article on the Infragistics blog

How to perform a CRUD operation on the jQuery igGrid with the ASP.NET Web API

In this post we will learn how to perform a CRUD operation on the igGrid using the ASP.NET Web API, including:

  • Creating the ASP.NET Web API using the Entity Framework database first approach
  • Performing a CRUD operation on the igGrid in a jQuery application

At the end of the post we should able to create Web API for CRUD operations on the City entity and perform the CRUD operations from the igGrid.

Read full article on the Infragistics blog

Proud to be part of PRAYAN to Empower Village Students


Read official news here on

View more photos here


PRAYAN is an initiative of C-SHARPCORNER to empower village students. As part of their program they visit nearby villages to Delhi and provide Internet education, career counseling to students from the village. I represented Infragistics in this noble cause and joined then C-Sharpcorner team On August 4, 2015, in an event for the students of “Choudhary Charan Singh Braj Khand Inter College, Bathain, Mathura.


This event was hosted in the same school in which Mahesh Chand founder of C-Sharpcorner did his schooling. It was emotional moment listening him while he was addressing students from his village and school.


Event was attended by around 1000 students, school teachers and villagers. Besides education and career counseling by Mahesh Chand, Kamal Rawat (Scientist Adobe) and me, there were arrangement of foods for the students.


I was impressed with the questions asked by the students and especially girls students. They all were very aspired and clear about their career objective. It was great moment interacting with students there.


I am happy to see the awareness level in the village and committed to be part of more such kind of events to help students who are the real future of our country.

View more photos here

Getting started with .NET unit testing using NUnit

It’s usually good practice to have automated unit tests while developing your code. Doing so helps you find bugs early in the development cycle and saves you time in the long run. These tests can be run by the developer multiple times to verify the behavior of a particular unit of code for different sets of input.

Unit tests essentially check the behavior of a particular unit of the code or the function, and are written by the developers who are implementing the functionalities.


We test the behavior of a function before it becomes part of the whole system and goes to production by writing a piece of code to test this behavior under different conditions. Usually a function gets tested in isolation with the other functions of the system under test (SUT).

Read full article on the Infragistics blog

Step by Step creating Hello World Native Android App using Xamarin

If you are a beginner with Xamarin, this post is here to help you get started. Step by step, we’re going to show you how to create a native Android app using Xamarin.

Xamarin allows us to create native Android and iOS apps using C#. In this post, we’ll assume you have downloaded and installed Xamarin, and we’re going to create the app in Xamarin Studio. Let’s see how it’s done:

Step 1: Create a New Project and App

To create an app, first we need to create a new solution. To do this, launch Xamarin Studio and from the menu select File->New->Solution (or alternatively press Ctrl+Shift+N) to create a new solution.


On the next window, you need to provide the app name and the identifier name. Let’s name the app MyFirstApp. Leave the target platforms and the theme to the default value and click on next as shown in the image below:

Read full article on Infragsitcs blog