Commits

Mario César Señoranis Ayala  committed 02ba480

Corregi malas referencias a llaves

  • Participants
  • Parent commits 7c71a60

Comments (0)

Files changed (3)

File Mangos.Apps/Inventory/Category.cs

             set { description = value; }
         }
         
-        [HasMany(typeof(Product), Table = "inventory_product", ColumnKey = "inventory_product_id")]
+        [HasMany(typeof(Product), Table = "inventory_product", ColumnKey = "id")]
         public IList Products {
             get { return products; }
             set { products = value; }

File Mangos.Apps/Inventory/Product.cs

             set { category = value; }
         }
 
-        [HasAndBelongsToMany(typeof(Venue), Table = "inventory_venues_products", ColumnKey = "inventory_product_id", ColumnRef = "inventory_venue_id")]
+        [HasAndBelongsToMany(typeof(Venue), Table = "inventory_venues_products", ColumnKey="inventory_product_id", ColumnRef = "inventory_venue_id")]
         public IList Venues {
             get { return venues; }
             set { venues = value; }
         }
         
+        public static Product FindById (int id)
+        {
+            return (Product)FindByPrimaryKey (typeof(Product), id);
+        }
     }
 }

File Mangos/MainWindow.cs

     
     public void PopulateProducts ()
     {
+        
+        /*
+        Inventory.Category nintendo = new Inventory.Category ();
+        Inventory.Category xbox = new Inventory.Category ();
+        nintendo.Name = "Nintendo";
+        nintendo.Description = "Nintendo";
+        xbox.Name = "XBox";
+        xbox.Description = "XBox360";
+        nintendo.Create ();
+        xbox.Create ();
         Inventory.Product product = new Inventory.Product ();
         product.Name = "Control inalábrico XBOX360 GREEN BAG";
         product.Description = "Control inalábrico XBOX360 GREEN BAG";
         product.BarCode = "200000000001";
+        product.Category = xbox;
         product.Create ();
         
         product = new Inventory.Product ();
         product.Name = "CHIP Desbloqueo XBOX360";
         product.Description = "CHIP Desbloqueo XBOX360";
         product.BarCode = "200000000002";
+        product.Category = xbox;
         product.Create ();
        
         product = new Inventory.Product ();
         product.Name = "Consola Xbox 360 ARCADE";
         product.Description = "Consola Xbox 360 ARCADE";
         product.BarCode = "200000000003";
+        product.Category = xbox;
         product.Create ();
         
         product = new Inventory.Product ();
         product.Name = "Nintendo Wii";
         product.Description = "Consola Nintendo Wii";
         product.BarCode = "200000000004";
+        product.Category = nintendo;
         product.Create ();
+        */
+        
+        Inventory.Product p1 = Inventory.Product.FindById(1);
+        Inventory.Product p2 = Inventory.Product.FindById (2);
+        
+        System.Console.WriteLine("{0}", p1.Name);
+        
     }
     
     protected virtual void OnPopularActionActivated (object sender, System.EventArgs e)