CodeSmith Community
Your Code. Your Way. Faster!

Yet an other question about foreign keys.

Latest post 09-23-2007 7:46 PM by Jerph. 4 replies.
  • 09-13-2007 2:21 AM

    • voeni
    • Not Ranked
    • Joined on 08-04-2007
    • Posts 8
    • Points 190

    Yet an other question about foreign keys.

    Hi all

    I work the first time in a ASP.NET project that uses Nettiers - so I'm really new in this topic.

    We have a lot of GridViews to show an overview of ongoing processes in our application. We have a tables like "Project" that are related to a "Status" table. All Projects are in a status that is related to "Status" table. All is working fine to this point.

    To show our projects with their current status we show a GridView. At this point I have to say, we use Infragistics UltraWebGrid (maybe a mistake, but we use it ;-).

    <igtbl:UltraWebGrid ID="grdProjects" runat="server" DataSourceID="datasource" SkinID="DefaultList">

    <Bands>

    <igtbl:UltraGridBand Key="Band 0" DataKeyField="ProID">

    <Columns>

    <igtbl:TemplatedColumn BaseColumnName="ProUniqueNumber" DataType="System.String" HeaderText="<%$ Resources:SchaweRE5, lblProNumber %>"

    IsBound="True" Key="ProUniqueNumber" SortIndicator="Ascending">

    <CellTemplate>

    <asp:HyperLink ID="lnkSelect" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"ProUniqueNumber") %>' NavigateUrl='<%# String.Format("~/Common/proDetail.aspx?ProID={0}", Eval("ProID")) %>' />

    </CellTemplate>

    <igtbl:TemplatedColumn BaseColumnName="ProStatusID" DataType="System.String" HeaderText="<%$ Resources:SchaweRE5, lblStatus %>"

    IsBound="True" Key="ProStatusID">

    <CellTemplate>

    <%# DataBinder.Eval(Container.DataItem,"ProStatusIDSource.StaMultilingualTitle") %>

    </CellTemplate>

    </igtbl:TemplatedColumn>

    </Columns>

    </igtbl:UltraGridBand>

    </Bands>

    </igtbl:UltraWebGrid>

    <data:ProjectDataSource ID="datasource" runat="server"

    SelectMethod="GetAll"

    EnablePaging="True" EnableDeepLoad="true"

    EnableSorting="True">

    <DeepLoadProperties Method="IncludeChildren" Recursive="False">

    <Types>

    <data:ProjectProperty Name="Status" />

    </Types>

    </DeepLoadProperties>

    </data:ProjectDataSource>

    This is working fine and show us an overview ,like:

    Project No. Status
    P0001 ongoing
    P0002 closed
    P0003 inactive

    But when I look on the SQL Profiler so I saw that each Status-text will be resolved in a separat query. Nettiers calls for each record in the "Project" table a stored procedure "exec dbo.sptStatus_GetByStaID @StaID=11". That is not sow heavy for only few projects, but we will getting thousands of projects!

    Can someone help me - or sy me waht I'm doing wrong?

    Thanks.

    Voeni

    • Post Points: 35
  • 09-13-2007 3:42 AM In reply to

    • swin
    • Top 10 Contributor
    • Joined on 06-14-2006
    • London, UK
    • Posts 925
    • Points 34,785

    Re: Yet an other question about foreign keys.

    Voeni,

    Unfortunately thats how it works. DeepLoading on a grid is not really recommended for large volumes of data (as you've realised). 

    There are a couple of work arounds though:

    1. Create a view for the data you wish to display (pulling in any referenced tables) and build your screen around that.

    2. Create a custom stored proc to do the same as (1).  When I just need a screen to display stuff this is generally what I do.

    3. Use the BoundDropDownField (if ultragrid lets you) to display the status description (set ReadOnly=true if necessary).  It will only read the datasource once for all of the rows.

    hth

    swin 

    ------------------------------------------------- Member of the .NetTiers team -------------------------------------------------
    • Post Points: 35
  • 09-21-2007 2:23 PM In reply to

    • Jerph
    • Not Ranked
    • Joined on 09-21-2007
    • Posts 8
    • Points 190

    Re: Yet an other question about foreign keys.

    An enhancement that would help this:

    For each type of deep loaded object, the DeepLoad method could be passed a delegate that would retrieve the relevant deep loaded entites.  Then netTiers could load the ...Source properties by matching to the primary keys, all in .NET code.

    For this example, DeepLoad would take a delegate that returns all status values that could possibly match to this list of projects.  In this case, it could be any of them. The call might look like this:

     DataRepository.ProjectProvider.DeepLoad(projects, false, DeepLoadType.IncludeChildren, typeof(Status), delegate(TList<Project> projects){ return DataRepository.StatusProvider.GetAll(); });

    This way, any kind of crazy deep load can be optimized if necessary, using a standard syntax. 

    • Post Points: 35
  • 09-23-2007 6:50 AM In reply to

    • voeni
    • Not Ranked
    • Joined on 08-04-2007
    • Posts 8
    • Points 190

    Re: Yet an other question about foreign keys.

    Hi Jerph

    I am very interrested in your example like:

    DataRepository.ProjectProvider.DeepLoad(projects, false, DeepLoadType.IncludeChildren, typeof(Status), delegate(TList<Project> projects){ return DataRepository.StatusProvider.GetAll(); });

    But I got some errors when trying it your way:

    (Located in an ASPX page)

    TList<Project> projects = Data.DataRepository.ProjectProvider.GetByProTypeID(9393);

    Data.DataRepository.ProjectProvider.DeepLoad(projects, false, DeepLoadType.IncludeChildren, typeof(Status), delegate(TList<Project> projects){return Data.DataRepository.StatusProvider.GetAll(); });

    I got following errors:

    • A local variable named 'projects' cannot be declared in this scope because it would give a different meaning to 'projects', which is already used in a 'parent or current' scope to denote something else 
    • The best overloaded method match for 'Data.Bases.EntityProviderBaseCore<Entities.Project,Entities.ProjectKey>.DeepLoad(Entities.TList<Entities.Project>, bool, Data.DeepLoadType, params System.Type[])' has some invalid arguments
    • Argument '5': cannot convert from 'anonymous method' to 'System.Type' 

    What I am doing wrong? Thanks for help...

     

    • Post Points: 35
  • 09-23-2007 7:46 PM In reply to

    • Jerph
    • Not Ranked
    • Joined on 09-21-2007
    • Posts 8
    • Points 190

    Re: Yet an other question about foreign keys.

    Sorry, I was suggesting that as an enhancement - it's not possible in .netTiers.  I should have put it in the feature request forums.  Sorry for the confusion!

    • Post Points: 5
Page 1 of 1 (5 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems