예제 #1
0
파일: Program.cs 프로젝트: MingLu8/Nemo
        private static void RunSelect(int count, bool cached, Nemo.Configuration.IConfiguration nemoConfig)
        {
            var connection = DbFactory.CreateConnection("DbConnection", nemoConfig);
            Expression <Func <Customer, bool> > predicate = c => c.Id == "ALFKI";

            connection.Open();

            // Warm-up
            var clonedConfig = ConfigurationFactory.CloneConfiguration(nemoConfig);

            clonedConfig.SetLogging(true).SetLogProvider(new ConsoleLoggingProvider());
            var result = ObjectFactory.Select <Customer>(null, connection: connection, cached: cached, config: clonedConfig).ToList();

            var timer = new Stopwatch();

            timer.Start();
            for (var i = 0; i < count; i++)
            {
                result = ObjectFactory.Select <Customer>(null, connection: connection, cached: cached, config: nemoConfig).ToList();
            }
            timer.Stop();
            connection.Close();

            Console.WriteLine("Nemo.Select: " + timer.Elapsed.TotalMilliseconds);
        }
예제 #2
0
파일: Program.cs 프로젝트: MingLu8/Nemo
        private static void RunRetrieve(int count, bool cached, Nemo.Configuration.IConfiguration nemoConfig)
        {
            var          connection = DbFactory.CreateConnection("DbConnection", nemoConfig);
            const string sql        = @"select CustomerID, CompanyName from Customers";

            //var parameters = new[] { new Param { Name = "CustomerId", Value = "ALFKI", DbType = DbType.String } };

            connection.Open();

            // Warm-up
            var clonedConfig = ConfigurationFactory.CloneConfiguration(nemoConfig);

            clonedConfig.SetLogging(true).SetLogProvider(new ConsoleLoggingProvider());
            var result = ObjectFactory.Retrieve <Customer>(connection: connection, sql: sql, /*parameters: parameters,*/ cached: cached, config: clonedConfig).ToList();

            var timer = new Stopwatch();

            timer.Start();
            for (var i = 0; i < count; i++)
            {
                result = ObjectFactory.Retrieve <Customer>(connection: connection, sql: sql, /*parameters: parameters,*/ cached: cached, config: nemoConfig).ToList();
            }
            timer.Stop();
            connection.Close();

            Console.WriteLine("Nemo.Retrieve: " + timer.Elapsed.TotalMilliseconds);
        }