Beispiel #1
0
        static void Main(string[] args)
        {
            //IDao<Product, int> productDao = new CoreDAO<Product, int>();//null ; // Inject.Get<IDao<Product, int>>
            //productDao.Get(4);

            var newProd = new Product
            {
                Name = "Burger6",
                ProductNumber = "ABC21",
                PriceCost = 1050,
                InvtType = new InventoryType { Id = 1 },
                Supplier = "Coles",
                PriceWholesale = 1300,
                BarCode = "12346436"
            };

            IDao dao = new CoreDao();
            dao.Save(newProd);

            ////IDao dao = null; // Inject.Get<IDao<Product, int>>
            ////dao.Get<Product, int>(4);

            //var allProds = dao.GetAll<Product>();

            //foreach (var prod in allProds) {
            //    System.Console.WriteLine("Product[name:" + prod.Name + "]");
            //}

            //var burger2Product = from p in dao.GetQueryable<Product>()
            //                     where p.Name == "Burger2"
            //                     select p;
            //System.Console.WriteLine("Test queryable ");
            //foreach (var prod in burger2Product)
            //{
            //    System.Console.WriteLine("Product[name:" + prod.Name + "]");
            //}

            //IDao dao = new CoreDAO();

            var p = dao.Get<Product, int>(1);

            dao.Save(p);

            System.Console.WriteLine("************UPDATE PRODUCT 1****************");
            System.Console.WriteLine(p.ToString());
            System.Console.WriteLine("************NEW PRODUCT****************");
            System.Console.WriteLine(newProd.ToString());

            System.Console.Read();
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            var dao = ServiceLocator.GetDAO<IDao<Product,int>>();

            Product p = new Product()
            {
                Description = textBox2.Text,
                Name = textBox1.Text,
                PriceCost = Decimal.Parse( textBox3.Text),
                ProductNumber = "34342"
            };

            dao.Save(p);

            //reload
            var allProducts = dao.GetAll();
            Reload(allProducts);
        }