示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Usefuldb4o Method: DB4ODatabases.GetCurrentContextContainer
            productsContainer = DB4ODatabases.GetCurrentContextContainer("ProductsDatabase");

            //If no data, fill with example info
            if (productsContainer.Query <Category>().Count == 0)
            {
                FillDatabase();
            }

            //show data
            foreach (var categoryItem in productsContainer.Query <Category>())
            {
                Response.Write(String.Format("{0}; {1}; <br />"
                                             , categoryItem.CategoryID
                                             , categoryItem.Name));

                foreach (var productItem in productsContainer.Query <Product>())
                {
                    Response.Write(String.Format("--> {0}; {1}; {2}; {3}; <br />"
                                                 , productItem.ProductID
                                                 , productItem.Name
                                                 , productItem.Price
                                                 , productItem.CategoryOfProduct.Name));
                }
            }
        }
示例#2
0
 public ProductsServices()
 {
     /*USEFULDB4O STAFF*/
     container = DB4ODatabases.GetCurrentContextContainer("Products");
 }