Пример #1
0
        public static void m2()
        {
            Builder builder = new Builder(
                typeof(SqlDataMapper <>),
                new Object[] { SqlMapperUnitTest.getMySqlConnectionString() },
                typeof(PropertyColumnMapper),
                typeof(ExplicitConnectionPolicy));

            IDataMapper <ProductSimple> productMapper            = builder.Build <ProductSimple>();
            IConnectionPolicy           explicitConnectionPolicy = productMapper.GetConnectionPolicy();

            // Act
            explicitConnectionPolicy.OpenConnection();
            explicitConnectionPolicy.BeginTransaction();

            ProductSimple p1 = productMapper.GetAll().First();

            p1.ProductName = "Potatoes";
            productMapper.Update(p1);

            ProductSimple p2 = productMapper.GetAll().First();

            // Assert
            bool result = p1.ProductName == p2.ProductName;

            explicitConnectionPolicy.RollBack();
            explicitConnectionPolicy.Dispose();
        }
Пример #2
0
        public static void m1()
        {
            Builder builder = new Builder(
                typeof(SqlDataMapper <>),
                new Object[] { SqlMapperUnitTest.getMySqlConnectionString() },
                typeof(PropertyColumnMapper),
                typeof(SingleConnectionPolicy));

            IDataMapper <ProductSimple> productMapper = builder.Build <ProductSimple>();
            IConnectionPolicy           policy        = productMapper.GetConnectionPolicy();

            ProductSimple p = productMapper.GetAll().First();

            p.ProductName = "Potatoes";
            productMapper.Update(p);

            ProductSimple p2 = productMapper.GetAll().First();

            p2.ProductName = "Chai";
            productMapper.Update(p2);

            ProductSimple novoP = new ProductSimple();

            novoP.ProductName     = "batatas";
            novoP.QuantityPerUnit = "setenta mil";
            productMapper.Insert(novoP);
        }