Using ExcludeIncludeFieldsList to load up in GridView

Posts   
 
    
Agsy
User
Posts: 5
Joined: 03-Dec-2008
# Posted on: 31-Dec-2008 04:07:12   

Hi Anyone,

I am just a newbie using LLBLGEN pro and I am having trouble using the "ExcludeIncludeFieldsList" to work on my code. I was trying to include a few selected fields to avoid fetching the entire columns in my table to my GridView and to speed up the entire query but so far I couldn't make it work. Can you help me out what is wrong with it?

I am currently using LLBLGenPro 2.6 Final and running under .NET 3.5.

Thanks.



public partial class DropRoutesQld : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ExcludeIncludeFieldsList includedFields = new ExcludeIncludeFieldsList();
            includedFields.Add(QldAddressDetailFields.MdsFullStreetName);
            includedFields.ExcludeContainedFields = false;

            PrefetchPath2 myPath = new PrefetchPath2((int)EntityType.CcdSdLinkEntity);
            myPath.Add(CcdSdLinkEntity.PrefetchPathQldAddressDetail,includedFields);
            _dsAdress.PrefetchPathToUse = myPath;

            IRelationPredicateBucket myInitFilter = new RelationPredicateBucket();
            myInitFilter.PredicateExpression.Add(new FieldCompareSetPredicate(QldAddressDetailFields.CdCode, null, CcdSdLinkFields.CdCode, null, SetOperator.In, ((CcdSdLinkFields.DmNum == "4206") & (CcdSdLinkFields.AddressDetailTable == "QLD_ADDRESS_DETAIL"))));
            _dsAdress.FilterToUse = myInitFilter;
        }
    }
}


    <div>
        <llblgenpro:LLBLGenProDataSource2 ID="_dsAdress" runat="server" EnablePaging="true" 
            AdapterTypeName="MyDRAGen.DatabaseSpecific.DataAccessAdapter, MyDRAGenDBSpecific" 
            DataContainerType="EntityCollection" 
            EntityFactoryTypeName="MyDRAGen.FactoryClasses.QldAddressDetailEntityFactory, MyDRAGen">
        </llblgenpro:LLBLGenProDataSource2>
        
        <dxwgv:ASPxGridView ID="_gridviewAddress" runat="server" DataSourceID="_dsAdress" AutoGenerateColumns="true">
        </dxwgv:ASPxGridView>
    
    </div>

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 31-Dec-2008 04:51:07   

Hi Agsy,

What are the real thing that doesn't work? I see that you are autogenereting columns on your (I guess) hierarchycal gridview, as you are using the ExcludeIncludeFieldsList on the prefetchpath. Remember that the goal of the ExcludeIncludeFieldsList feature is fetch a subset of the fields of an entity for performance reasons. That doesn't mean that the object only have some fields. What the feature says is: exlude these fields as they are too big and I want to improve the performance on roundtrips. If you inspect the generated sql you will notice that only a subset of fields are fetched. So, maybe you need to customize the declarative gridview to include only those fields you want to show.

Hope helpful simple_smile

David Elizondo | LLBLGen Support Team
Agsy
User
Posts: 5
Joined: 03-Dec-2008
# Posted on: 31-Dec-2008 08:18:42   

Thanks for your reply Daelmo. Sorry I didn't specify the real problem, what had happened if you look on my code as I specified 1 field (just to test it) - "QldAddressDetailFields.MdsFullStreetName" in ExcludeIncludeFieldsList includedFields. However when I look at the actual SQL statement generated by LLBLGEN using the SQL Server 2005 Profiler (to trace the actual command that passes to the SQL server) it was including ALL the columns or fields from the table I was fetching.

By the way I set the property to - "includedFields.ExcludeContainedFields" to false to do "inclusion" instead of exclusion as per my understanding. confused As my purpose is to include only the field I specified.

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 31-Dec-2008 08:51:42   

<llblgenpro:LLBLGenProDataSource2 ID="_dsAdress" runat="server" EnablePaging="true" AdapterTypeName="MyDRAGen.DatabaseSpecific.DataAccessAdapter, MyDRAGenDBSpecific" DataContainerType="EntityCollection" EntityFactoryTypeName="MyDRAGen.FactoryClasses.QldAddressDetailEntityFactory, MyDRAGen"> </llblgenpro:LLBLGenProDataSource2>

The datasource is fetching QldAddressDetailEntity.

PrefetchPath2 myPath = new PrefetchPath2((int)EntityType.CcdSdLinkEntity); myPath.Add(CcdSdLinkEntity.PrefetchPathQldAddressDetail,includedFields); _dsAdress.PrefetchPathToUse = myPath;

And you are using a prefetchPath with a root of CcdSdLinkEntity, which has nothing to do with the fetched entities.

You should disable LivePersistence and pass the ExcludeIncludeFieldsList collection to the fetch method in the PerformSelect event handler.

rtbike
User
Posts: 23
Joined: 23-Jan-2009
# Posted on: 23-Jan-2009 02:13:53   

sorry - meant to create a new thread - not add to this post