protected void EsDataSource1_esCreateEntity(object sender, EntitySpaces.Web.esDataSourceCreateEntityEventArgs e)
    {
        ProductsQuery p = new ProductsQuery("p");
        CategoriesQuery c = new CategoriesQuery("c");

        p.Select(p, c.CategoryName);
        p.InnerJoin(c).On(p.CategoryID == c.CategoryID);

        if (e.PrimaryKeys != null)
        {
            p.Where(p.ProductID == (int)e.PrimaryKeys[0]);
        }
        else
        {
            // They want to add a new one, lets do a select that brings back
            // no records so that our CategoryName column (virutal) will be
            // present in the underlying record format
            p.Where(1 == 0);
        }

        Products prd = new Products();
        prd.Load(p);  // load the data (if any)

        // Assign the Entity
        e.Entity = prd;
    }
        public ProductsCollection Products_LoadWithExtraColumn()
        {
            ProductsQuery p = new ProductsQuery("p");
            SuppliersQuery s = new SuppliersQuery("s");

            // Bring back the suppliers name for the Product from the Supplier table
            p.Select(p, s.CompanyName.As("SupplierName"));
            p.InnerJoin(s).On(p.SupplierID == s.SupplierID);

            ProductsCollection coll = new ProductsCollection();
            coll.Load(p);

            return coll;
        }
    protected void EsDataSource1_esSelect(object sender, EntitySpaces.Web.esDataSourceSelectEventArgs e)
    {
        ProductsQuery p = new ProductsQuery("P");
        CategoriesQuery c = new CategoriesQuery("c");

        // All columns from our products table and the CategoryName from the Category table, we really do not
        // display all of the product fields so I could have selected individual fields out of the products
        // table
        p.Select(p, c.CategoryName);
        p.InnerJoin(c).On(p.CategoryID == c.CategoryID);

        // We supply the Collection and the Query, because we're letting the grid to auto paging and
        // auto sorting. Otherwise, we could just load the collection ourselves and only supply the
        // collection
        e.Collection = new ProductsCollection();
        e.Query = p;
    }