.Net C# using the Dapper ORM

A quick look at the Dapper ORM and a simple example to grab some data from a SQL Server.

using System;
using System.Data.SqlClient;
using Dapper;

namespace CsharpDapperDemo
{
    /// <summary>
    /// Simple demonstration of the Dapper ORM.
    /// </summary>
    class CsharpDapperExample
    {
        static void Main()
        {
            const string myConnectionString = @"Data Source=MYSQLSERVER\SQLEXPRESS;Database=Company;Integrated Security=True;Connect Timeout=15;Encrypt=False";

            using (var connection = new SqlConnection(myConnectionString))
            {
                connection.Open();

                var companyDataResults  = connection.Query<CompanyData>("select * from dbo.EmployeeInfo");

                foreach (var result in companyDataResults)
                    Console.WriteLine("{0} {1} {2} {3} {4}", result.Empno, result.EmpName, result.Salary,
                                      result.DeptName, result.Designation);

                Console.ReadKey();
            }
        }

        /// <summary>
        /// Class for testing results from Dapper.
        /// </summary>
        private class CompanyData
        {
            public int Empno;
            public string EmpName;
            public int Salary;
            public string DeptName;
            public string Designation;
        }
    }
}