ASP.NET MVC is a presentation framework. MVC stands for Model-View-Controller. Model gives a notion that it is related to data access. However, it is just a data abstraction for the view. It can be thought of a ViewModel.

Apart from MVC, a large ASP.NET application deals with services. It also deals with data access. We need a good project structure. In the post, we build a simple Hello world project.…

Read More

ASP.NET Identity Framework 2.0 is integrated with EntityFramework. The entity classes available are Users, Roles, Claims and Logins. The Identity database can be any store – SQL Server, MySQL or Oracle. This article provides guidance on how to integrate ASP.NET Identity 2.0 with a MySQL database.

SQL scripts for MySQL

MySQL has naming conventions which are very different from SQL Server.…

Read More

Today, I had a chance to use Fisher Yates algorithm. Fisher Yates algorithm shuffles the items in a list.

Here is the problem statement:

Out of an array of N items, randomly pick K items where 0 < K < N.

My first naive solution of the problem was as follows:

IEnumerable<int> RandomSelect(int n, int k)
{
    var random = new Random();
    var set = new HashSet<int>();
    while(set.Count
Read More

AngularJS allows to define async functions. An example is the $http service. HTTP service calls an API and returns a response as a promise.

$http.get(url)
    .then(function(res){
        // handle the response
    }, function(res){
        // handle the error
    });

Retrieve the result from the Promise object using then function. The function has two arguments: onSuccess callback and onFailure callback.

The $q service in AngularJS creates a promise using the defer function.…

Read More

Entity Framework is an ORM framework for .NET applications. We specify the mapping between .NET classes and corresponding database tables. Tables are related to one another. The common relations are One-to-One, One-to-Many or Many-to-Many.

  • One-to-One: Record in TableA maps to a record in TableB.
  • One-to-Many: Record in TableA maps to multiple records in TableB.
  • Many-to-Many: Record in TableA maps to multiple records in TableB and one record in TableB maps to multiple records in TableA.
Read More

Elastic is a search engine built on top of Lucene. We build Auto-complete capability with Elastic.

Setting up Elastic

Download the zip file from Elastic site. Extract the zip file to a suitable folder. From the bin folder, run service.bat install. In the service manager, adjust the settings for the service. If you encounter Java errors, install Java runtime (8) from Oracle website.…

Read More

Google Maps Javascript API is very easy to use. In this article, we display a map with location markers.

Get an API Key for Google Maps. Use the API Key in the script tag.

<script src="https://maps.googleapis.com/maps/api/js?key=AIz.....zvT9Y">
</script>

Create a map object with few options. Map options include an initial zoom and center location. Specify location using LatLng object having latitude and longitude.…

Read More