using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace GetBigTable
{
	class Program
	{
		static void Main(string[] args)
		{
            /*
			IsolationLevel iso;
			if (args[0] == "nolock")
				iso = IsolationLevel.ReadUncommitted;
			else
				iso = IsolationLevel.ReadCommitted;
             * */

			using (SqlConnection conn = new SqlConnection("server=.;integrated security=sspi;database=pubs"))
			using (SqlCommand cmd = new SqlCommand("select * from bigtable order by col1", conn))
			{
				SqlDataReader rdr = null;
				SqlTransaction tx = null;

				conn.Open();
				tx = conn.BeginTransaction(IsolationLevel.Serializable);
				cmd.Transaction = tx;
				rdr = cmd.ExecuteReader();

                int i = 0;

				// read the rest
				while (rdr.Read())
                {
					i++;
                }
				rdr.Close();
				tx.Commit();
                Console.WriteLine(i);
				Console.WriteLine("Done. Press enter to continue");
				Console.ReadLine();
			}
		}
	}
}
