Exemplo n.º 1
0
 public Product GetById(Guid id)
 {
     using (var connection = context.CreateConnection())
     {
         return(connection.Query <Product>(SelectProduct.ById(id)).SingleOrDefault());
     }
 }
Exemplo n.º 2
0
        public void UpdateProductName()
        {
            using (IDbConnection dbConnection = new SqliteConnectionFactory().Create())
            {
                var insertProduct = new InsertProduct();
                var product = new ProductDto {Name = "Product Name"};
                product.Id = (int) dbConnection.Query<Int64>(insertProduct.Query(product)).Single();

                var updateProduct = new UpdateProduct();
                dbConnection.Execute(updateProduct.NameForAllProducts("new name"));

                var selectProduct = new SelectProduct();
                ProductDto result = dbConnection.Query<ProductDto>(selectProduct.ById(product.Id)).Single();

                StringAssert.AreEqualIgnoringCase("new name", result.Name);
            }
        }
Exemplo n.º 3
0
        public void UpdateProductName()
        {
            using (IDbConnection dbConnection = new SqliteConnectionFactory().Create())
            {
                var insertProduct = new InsertProduct();
                var product       = new ProductDto {
                    Name = "Product Name"
                };
                product.Id = (int)dbConnection.Query <Int64>(insertProduct.Query(product)).Single();

                var updateProduct = new UpdateProduct();
                dbConnection.Execute(updateProduct.NameForAllProducts("new name"));

                var        selectProduct = new SelectProduct();
                ProductDto result        = dbConnection.Query <ProductDto>(selectProduct.ById(product.Id)).Single();

                StringAssert.AreEqualIgnoringCase("new name", result.Name);
            }
        }