Ejemplo n.º 1
0
        private static void Main(string[] args)
        {
            var container = new Container();

            ContainerManager.RegisterComponentsTo(container);

            int customerId = 0;
            var dapperConnectionFactory =
                new DapperConnectionFactory(
                    new ConnectionStringProvider()
            {
                ConnectionString =
                    ConfigurationManager.ConnectionStrings["CqsContext"]
                    .ConnectionString
            });

            using (var dapperConnection = dapperConnectionFactory.CreateConnection())
            {
                dapperConnection.Open();
                customerId =
                    dapperConnection.Query <int>("Select Id from Customer where  LastName like 'Rogers'")
                    .First();
            }

            Console.WriteLine("NB - this test takes about 2 mins to run. Stick with it, it is worth it!");
            Console.WriteLine("");

            RunEfStandardQueries(container, customerId);
            RunEfProjectionQueries(container, customerId);
            RunDapperSprocQueries(container, customerId);
            RunDapperExtensionsQueries(container, customerId);
            RunDapperAsyncQueries(container, customerId);

            Console.ReadLine();
        }
Ejemplo n.º 2
0
        private static void Main(string[] args)
        {
            Console.WriteLine("Creating Cqs Database...");
            using (var cqsContext = new CqsCommandContext())
            {
                var customer = cqsContext.Customers.FirstOrDefault();
            }

            Console.WriteLine("Created Cqs Database...");


            var dapperConnectionFactory = new DapperConnectionFactory(new ConnectionStringProvider()
            {
                ConnectionString = ConfigurationManager.ConnectionStrings["CqsContext"].ConnectionString
            });

            using (var dapperConnection = dapperConnectionFactory.CreateConnection())
            {
                dapperConnection.Open();
                Console.WriteLine("Adding Sprocs into the Cqs Database...");

                dapperConnection.Execute(BuildDropSproc("usp_Read_Customer"));
                dapperConnection.Execute(BuildDropSproc("usp_Read_Order"));
                dapperConnection.Execute(BuildSproc("usp_Read_Customer"));
                dapperConnection.Execute(BuildSproc("usp_Read_Order"));

                Console.WriteLine("Inserting data into the Cqs Database...");

                dapperConnection.Execute(BuildInsertCustomersSql("Joe", "Bloggs", "*****@*****.**"));
                var customerId = dapperConnection.Query <int>(BuildInsertCustomersSql("Sean", "Rogers", "*****@*****.**"))
                                 .First();

                AddOrdersToCustomer(dapperConnection, customerId);
            }

            Console.WriteLine("Database successfully created and seeded.");

            Console.ReadLine();
        }