The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

webadmin template issue

Last post 08-27-2008, 2:13 AM by seanrock. 5 replies.
Sort Posts: Previous Next
  •  08-22-2008, 1:51 AM 10870

    webadmin template issue

    Hi

    this is the first time i've tried to use the admin templates and i've run into a problem. got two tables [User] and [Address] User table has a pk UserId and Address table has an fk of UserId as well. i'm generating a admin control for the User table and i select the Address table on the Details Grids tab under the list of foreign keys. I've created a view of the Address table as only views are shown in the drop down (p.s. this drop down is not mentioned in the help doc - but i'm assuming its defining the columns to show in the detail grid) following the screen-shot in the help doc and selected the UserId column from the second dropdown. in the list of fields below that i've select a couple of columns to display in the detail grid. i've also tried without selecting a view. now when i generate my admin control there is a method generated:

     

    Code:
    private void gdFK_Address_UserLoad()
    {

    UserCollection obj = new UserCollection();
    obj.Query.Select
    (

    obj.Query.Id,

    obj.Query.Name,

    obj.Query.Line1,

    obj.Query.Line2,

    obj.Query.City,

    obj.Query.County,

    obj.Query.Country,

    obj.Query.Postcode
    )
    .Where(obj.Query.UserId.Equal(this.Id));


    string sortExpression = this.GetSortExpression("FK_Address_User");
    if (sortExpression != "")
    obj.Query.OrderBy(sortExpression, GetSortDirectionEnum("FK_Address_User"));

    if (!obj.Query.Load())
    {
    // Force it to show headers but disable "Select"
    obj.AddNew();
    this.gdFK_Address_User.Columns[0].Visible = false;
    }

    this.gdFK_Address_User.DataSource = obj;
    this.gdFK_Address_User.DataBind();
    }

     You can see that it is instantiating an instance of the UserCollection class however the Query is using the columns from the Address table. I thought that maybe my relationship was wrong however my es classes are generated and working correctly.

    any idea what i'm doing wrong? 

     

    Thanks

    p.s. keep up the good work guys! you're doing a fantastic job!

     

     


    Sean Rock
  •  08-22-2008, 8:37 AM 10874 in reply to 10870

    Re: webadmin template issue

    I'm confused, this seems correct to me.

    Take a look at this POST.

    And then look at our DEMO

    You can use these two links to see what options I chose to geneate the demo.


    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  08-22-2008, 12:31 PM 10877 in reply to 10874

    Re: webadmin template issue

    Hi Mike and thanks for the reply. in the code above the method is in the user_admin.ascx control and a UserCollection object is instantiated however in the query select the columns belong to the Address table, not the User table.

    Sean Rock
  •  08-26-2008, 4:14 AM 10909 in reply to 10874

    Re: webadmin template issue

    Hi Mike

    well i followed the examples you've listed and i was doing exactly the same thing. So i decided to look at the template and found an issue (well i think its an issue as i changed it and now it works fine).

    basically in the foreign key section the method in question looks like this:

     

    Code:
    private void gd<%=fkName%>Load()
    {
    <% source = new EntitySpaces.PlugIn.esPluginSource(table, null); %>
    ...etc...
    }

     

     i simple changed the first line to read

     

    Code:
    <% source = new EntitySpaces.PlugIn.esPluginSource(fk.ForeignTable, null); %>
     

     and now it works fine, the proper table (the foreign key table) is instantiated and not the primary key table, which was happening before.


    Sean Rock
  •  08-26-2008, 5:08 AM 10912 in reply to 10874

    Re: webadmin template issue

    When selecting a view object on the browse tab, the same columns are shown on the search tab. this fine of course, but the method that is generated, i.e. LoadEntityForSearch is using the primary key table. for example, i created a view OrderView, but the method LoadEntityForSearch is taking (in my case) as its parameter an instance of OrderCollection and query select is outputing the selected colums from the search tab which belong to the OrderView object so a compile error occurrs.



    Sean Rock
  •  08-27-2008, 2:13 AM 10955 in reply to 10874

    Re: webadmin template issue

    well i've updated to the latest release of ES and still i'm having the same problems as described above. Mike is it possible for you to post the templates you used to generate the demo because the current webamin templates dont seem to work as illustrated. thanks.

    Sean Rock
View as RSS news feed in XML