mapping fields

Posts   
 
    
nis07
User
Posts: 35
Joined: 01-Nov-2008
# Posted on: 17-Nov-2008 21:38:16   

dsmachine - table name Fields mapped on related fields AitNo (from table Ait) & appnm(frpm app table)

below is the code added in the DAL\Entitclass\dsmachineentity.cs

 private static void SetupCustomPropertyHashtables()
        {_fieldsCustomProperties.Add("AitNo", fieldHashtable);
            fieldHashtable = new Dictionary<string, string>();

            _fieldsCustomProperties.Add("appnm", fieldHashtable);
            fieldHashtable = new Dictionary<string, string>();
        }
public virtual System.String AitNo
        {
            get { return (System.String)GetValue((int)AitFieldIndex.AitNo, true); }
        }
public virtual System.String appnm
        {
            get { return (System.String)GetValue((int)AppFieldIndex.appnm, true); }
        }

when I try to retrive the data from a gridview the data for both the columns appears same. (In DB AitNo is 3 & appnm is nm --> In grid view its displayed as AitNo-ASSm & appnm-ASSm)

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 18-Nov-2008 04:58:10   

Please post the declarative aspx of your grid and LLBLGenProDataSource. Also, please test with a ConsoleTest or something to see if this is related to LLBLGen or some databinding thing.

And please post more information.

David Elizondo | LLBLGen Support Team
nis07
User
Posts: 35
Joined: 01-Nov-2008
# Posted on: 18-Nov-2008 15:46:45   

daelmo wrote:

Please post the declarative aspx of your grid and LLBLGenProDataSource. Also, please test with a ConsoleTest or something to see if this is related to LLBLGen or some databinding thing.

And please post more information.

Hi daelmo below is the aspx content.

<llblgenpro:LLBLGenProDataSource2 ID="Instance" runat="server" AdapterTypeName="EN.DAL.DatabaseSpecific.DataAccessAdapter, EN.DALDBSpecific" DataContainerType="EntityCollection" EntityFactoryTypeName="EN.DAL.FactoryClasses.dsmachineEntityFactory, EN.DAL" >
                        <SelectParameters>
                            <asp:ControlParameter ControlID="GMList" Name="MId" PropertyName="SelectedValue" Type="String"/>
                        </SelectParameters>
                    </llblgenpro:LLBLGenProDataSource2> 

<asp:GridView ID="GInstances" runat="server" AllowPaging="True" DataSourceID="Instance" AutoGenerateColumns="False">                                           <Columns>                            
                                    <asp:TemplateField HeaderText="AIT">                                    
                                       <ItemTemplate>
                                           <asp:TextBox ID="lait" runat="server" Text='<%# Bind("AitNo") %>' Width="100px" />
                                       </ItemTemplate></asp:TemplateField>                              
        <asp:TemplateField HeaderText="Application">                                    
                                       <ItemTemplate>
<asp:TextBox ID="lappnm" runat="server" Text='<%# Bind("AppnNm") %>' Width="100px"/>
                                       </ItemTemplate></asp:TemplateField>
<asp:TemplateField HeaderText="Instance">                                   
                                       <ItemTemplate>
                                           <asp:TextBox ID="lInst" runat="server" Width="100px" Text='<%# Bind("Instance") %>'/>
                                       </ItemTemplate> </asp:TemplateField>
                                   </Columns>                                                                   
                                </asp:GridView> 

when I execute I dont get any error but all the three columns display the same content. Fields mapped on relations - AppNm, AitNo (m:1 relation) Fields maped on database fields - Instance

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 18-Nov-2008 21:49:07   

Is your dsMachine Entity pre-fetched with the child entities that the other mapped fields come from ?

Can you access the values you are expecting from a test winforms or console app ?

nis07
User
Posts: 35
Joined: 01-Nov-2008
# Posted on: 19-Nov-2008 14:51:52   

MTrinder wrote:

Is your dsMachine Entity pre-fetched with the child entities that the other mapped fields come from ?

Can you access the values you are expecting from a test winforms or console app ?

yes I can access the values. If you want to look at the code I can post it in helpdesk.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 19-Nov-2008 16:17:02   

Just to make sure: - The relationg between dsmachineEntity and AitNo is m:1 - Also the relationg between dsmachineEntity and AppNm is m:1

Which LLBLGen Pro runtime library version are you using? Did you add these fields from the designer's "fields on related fields" tab?

Would you please attach the lgp project in a helpdesk thread.

nis07
User
Posts: 35
Joined: 01-Nov-2008
# Posted on: 19-Nov-2008 16:28:39   

Walaa wrote:

Just to make sure: - The relationg between dsmachineEntity and AitNo is m:1 - Also the relationg between dsmachineEntity and AppNm is m:1

Which LLBLGen Pro runtime library version are you using? Did you add these fields from the designer's "fields on related fields" tab?

Would you please attach the lgp project in a helpdesk thread.

yes the relation is m:1 llblgen version 2.6 yes I used fields on related fields tab. I will post mylgp in helpdesk walaa.

nis07
User
Posts: 35
Joined: 01-Nov-2008
# Posted on: 19-Nov-2008 16:48:21   

I posted my lgp in the helpdesk walaa

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 19-Nov-2008 17:02:53   

I'll check the helpdesk thread.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 19-Nov-2008 17:10:20   

I checked the helpdesk thread, and contrary to the code you have posted the following is the generated code for one of the field on related field properties:

        public virtual System.String AitNmbr
        {
            get
            {
                AppAitEntity relatedEntity = this.AppAit;
                if(relatedEntity!=null)
                {
                    return relatedEntity.AitNmbr;
                }
                else
                {
                    return (System.String)TypeDefaultValue.GetDefaultValue(typeof(System.String));
                }
            }
            set
            {
                AppAitEntity relatedEntity = this.AppAit;
                if(relatedEntity!=null)
                {
                    relatedEntity.AitNmbr = value;
                }               
            }
        }   

Which looks perfectly fine for me. That's why I have to ask this again, did you pass a prefetchPath object to the LLBLGenProDataSource? Which should do the trick and fetch the related object and hence populate the field mapped on it.

nis07
User
Posts: 35
Joined: 01-Nov-2008
# Posted on: 19-Nov-2008 17:20:00   

Walaa wrote:

I checked the helpdesk thread, and contrary to the code you have posted the following is the generated code for one of the field on related field properties:

        public virtual System.String AitNmbr
        {
            get
            {
                AppAitEntity relatedEntity = this.AppAit;
                if(relatedEntity!=null)
                {
                    return relatedEntity.AitNmbr;
                }
                else
                {
                    return (System.String)TypeDefaultValue.GetDefaultValue(typeof(System.String));
                }
            }
            set
            {
                AppAitEntity relatedEntity = this.AppAit;
                if(relatedEntity!=null)
                {
                    relatedEntity.AitNmbr = value;
                }               
            }
        }   

Which looks perfectly fine for me. That's why I have to ask this again, did you pass a prefetchPath object to the LLBLGenProDataSource? Which should do the trick and fetch the related object and hence populate the field mapped on it.

no I dont think did any prefetchpath to LLBLGenProDataSource. I just used the llbgenprodatasouce2 to the gridview as below

</llblgenpro:LLBLGenProDataSource2>   
                    <llblgenpro:LLBLGenProDataSource2 ID="ODSInstance" runat="server" AdapterTypeName="ENVWeb.DAL.DatabaseSpecific.DataAccessAdapter, ENVWeb.DALDBSpecific" DataContainerType="EntityCollection" EntityFactoryTypeName="ENVWeb.DAL.FactoryClasses.VDbsBymachineEntityFactory, ENVWeb.DAL" >
                        <SelectParameters>
                            <asp:ControlParameter ControlID="GVMachineViewList" Name="MachineId" PropertyName="SelectedValue" Type="String"/>
                        </SelectParameters>
                    </llblgenpro:LLBLGenProDataSource2> 
<asp:GridView ID="GVInstances" runat="server" DataSourceID="ODSInstance" AutoGenerateColumns="False">                                          <Columns>
                            
                                    <asp:TemplateField HeaderText="AIT Number">                                 
                                       <ItemTemplate>
                                           <asp:TextBox ID="lblaitnmbr" runat="server" Text='<%# Bind("Aitnmbr") %>' Width="100px" />
                                       </ItemTemplate>
                                    </asp:TemplateField>
                                
                                    <asp:TemplateField HeaderText="Application Name">                                   
                                       <ItemTemplate>
                                           <asp:TextBox ID="lblapplicationshortnm" runat="server" Text='<%# Bind("ApplicationShortNm") %>' Width="100px"/>
                                       </ItemTemplate>
                                    </asp:TemplateField>                                
                                   </Columns> 
                                                                
                                </asp:GridView> 

where is the prefetch done?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 19-Nov-2008 17:26:40   

You should pass a prefetchPath obejct to the LLBLGenProDataSource's PrefetchPathToUse property to fetch the related entities along with the main entity.

This can be set at code behind, at Page_Load for example.

nis07
User
Posts: 35
Joined: 01-Nov-2008
# Posted on: 19-Nov-2008 18:58:25   

Walaa wrote:

You should path a prefetchPath obejct to the LLBLGenProDataSource's PrefetchPathToUse property to fetch the related entities along with the main entity.

This can be set at code behind, at Page_Load for example.

ODSInstance.PrefetchPathToUse = new PrefetchPath2((int)EntityType.VDbsBymachineEntity);
            ODSInstance.PrefetchPathToUse.Add(VDbsBymachineEntity.PrefetchPathAppAit);
            ODSInstance.PrefetchPathToUse.Add(VDbsBymachineEntity.PrefetchPathApplication);

Thanks for the help walaa I got the applicationashortnm working & for the other I will recheck the data. Do we need to do the same prefetch for the "fields mapped on relation"?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 20-Nov-2008 05:10:21   

Do we need to do the same prefetch for the "fields mapped on relation"?

Yes. If you want to access a related field mapped on a relation you should prefetch the related collection. Suppose you have an OrderEntity with a "CustomerName" related field (via Order.Customer.CustomerName). You should prefetch the Order.Customer entity to be able to access the related CustomerName field.

David Elizondo | LLBLGen Support Team