Exemplo n.º 1
0
        static void Main(string[] args)
        {
            String connString = "Data Source=(local);Initial Catalog=master;Integrated Security=True;Asynchronous Processing=true;";

            OperateDatabase.CreateDatabase(connString);
            Console.WriteLine();

            Console.WriteLine("Demonstrate the ReadUncommitted transaction: ");
            TransactionIsolationLevels.DemonstrateIsolationLevel(connString,
                                                                 System.Data.IsolationLevel.ReadUncommitted);
            Console.WriteLine("-----------------------------------------------");

            Console.WriteLine("Demonstrate the ReadCommitted transaction: ");
            TransactionIsolationLevels.DemonstrateIsolationLevel(connString,
                                                                 System.Data.IsolationLevel.ReadCommitted);
            Console.WriteLine("-----------------------------------------------");

            Console.WriteLine("Demonstrate the RepeatableRead transaction: ");
            TransactionIsolationLevels.DemonstrateIsolationLevel(connString,
                                                                 System.Data.IsolationLevel.RepeatableRead);
            Console.WriteLine("-----------------------------------------------");

            Console.WriteLine("Demonstrate the Serializable transaction: ");
            TransactionIsolationLevels.DemonstrateIsolationLevel(connString,
                                                                 System.Data.IsolationLevel.Serializable);
            Console.WriteLine("-----------------------------------------------");

            Console.WriteLine("Demonstrate the Snapshot transaction: ");
            OperateDatabase.SetSnapshot(connString, true);
            TransactionIsolationLevels.DemonstrateIsolationLevel(connString,
                                                                 System.Data.IsolationLevel.Snapshot);
            Console.WriteLine("-----------------------------------------------");

            Console.WriteLine("Demonstrate the difference between the Snapshot and Serializable transactions:");
            TransactionIsolationLevels.DemonstrateBetweenSnapshotAndSerializable(connString);
            OperateDatabase.SetSnapshot(connString, false);
            Console.WriteLine();
        }