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;
    }
    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;
    }
        public static string GetFktString(EntitySpaces.Interfaces.esConnection conn)
        {
            ConnectionStringSettings settings;
            string fktString = "";

            switch (conn.ProviderSignature.DataProviderName)
            {
                case "EntitySpaces.SqlServerCeProvider":
                    settings =
                        ConfigurationManager.ConnectionStrings["SqlCeFkt"];
                    fktString = settings.ConnectionString;
                    break;

                case "EntitySpaces.SqlServerCe4Provider":
                    settings =
                        ConfigurationManager.ConnectionStrings["SqlCe4Fkt"];
                    fktString = settings.ConnectionString;
                    break;

                case "EntitySpaces.OracleClientProvider":
                    settings =
                        ConfigurationManager.ConnectionStrings["OracleFkt"];
                    fktString = settings.ConnectionString;
                    break;

                case "EntitySpaces.MSAccessProvider":
                    settings =
                        ConfigurationManager.ConnectionStrings["AccessFkt"];
                    fktString = settings.ConnectionString;
                    break;

                case "EntitySpaces.VistaDBProvider":
                    settings =
                        ConfigurationManager.ConnectionStrings["VistaDBFkt"];
                    fktString = settings.ConnectionString;
                    break;

                case "EntitySpaces.VistaDB4Provider":
                    settings =
                        ConfigurationManager.ConnectionStrings["VistaDB4Fkt"];
                    fktString = settings.ConnectionString;
                    break;

                case "EntitySpaces.SQLiteProvider":
                    settings =
                        ConfigurationManager.ConnectionStrings["SQLiteFkt"];
                    fktString = settings.ConnectionString;
                    break;

                case "EntitySpaces.NpgsqlProvider":
                case "EntitySpaces.Npgsql2Provider":
                    settings =
                        ConfigurationManager.ConnectionStrings["PgsqlFkt"];
                    fktString = settings.ConnectionString;
                    break;

                case "EntitySpaces.MySqlClientProvider":
                    settings =
                        ConfigurationManager.ConnectionStrings["MySQLFkt"];
                    fktString = settings.ConnectionString;
                    break;

                case "EntitySpaces.SybaseSqlAnywhereProvider":
                    settings =
                        ConfigurationManager.ConnectionStrings["SybaseFkt"];
                    fktString = settings.ConnectionString;
                    break;

                default:
                    settings =
                        ConfigurationManager.ConnectionStrings["SqlServerFkt"];
                    fktString = settings.ConnectionString;
                    break;
            }

            return fktString;
        }
    protected void EsDataSource1_esException(object sender, EntitySpaces.Web.esDataSourceExceptionEventArgs e)
    {
        this.Response.Write("ERROR");
        this.Response.Write("<BR><hr>");
        this.Response.Write(e.TheException.Message);
        this.Response.Write(e.SelectArgs.Query.es.LastQuery);
        this.Response.Write("<hr><br><br>");

        e.ExceptionWasHandled = true;
    }