PrefetchPath issue

Posts   
 
    
jovball
User
Posts: 443
Joined: 23-Jan-2005
# Posted on: 13-Jul-2009 13:56:52   

LLBLGen runtime 2.6.9.616

I'm trying to use a prefetch path with an asp.net FormView and the display is showing the entity type rather than the actual data.

By using Profiler, I can see that the related information is being retrieved so I believe that the code is correct. However, the FormView display shows

MyNamespace.DAL.EntityClasses.PaymentMethodTypeEntity

The entity name and the field name are both the same (PaymentMethodType). I don't know if that is what is causing the problem or not.

Any ideas would be appreciated.

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 13-Jul-2009 14:02:34   

The entity name and the field name are both the same (PaymentMethodType). I don't know if that is what is causing the problem or not.

Might be, but we can't tel without seeing some code, could you please post the FormView aspx code. (Only the item template can be sufficient to show how you bind to the related entity's field).

jovball
User
Posts: 443
Joined: 23-Jan-2005
# Posted on: 13-Jul-2009 15:56:16   

OK, here is the .cs code and the FormView code.

first, the FormView


        

        <ItemTemplate>
            <table style="width: 500px;" class="CssColumnForm"> 
            
            
                <tr>
                    <th class="dataLabel" scope="row"  style="width: 150px; text-align:right;">
                        ID
                    </th>
        
                    <td class="dataCell" style="text-align:left">
                    <asp:Label ID="lblId" runat="server" 
                        Text='<%# Eval("ProductPartnerPaymentId", "{0:f0}")%>' />
                    </td> 
                </tr>
            
                            
                <tr>
                    <th class="dataLabel" scope="row" style="text-align:right;">                    
                            Product Partner Id                  
                    </th>
                    <td class="dataCell" style="text-align:left;">
                        <asp:Label ID="lblProductPartnerId" runat="server" 
                            Text='<%# Eval("ProductPartnerId", "{0:f0}")%>' />
                    </td>
                </tr> 
                
                <tr>
                    <th class="dataLabel" scope="row" style="text-align:right;">                    
                            Payment Method              
                    </th>
                    <td class="dataCell" style="text-align:left;">
                        <asp:Label ID="lblPaymentMethodTypeId" runat="server" 
                            Text='<%# Eval("PaymentMethodType")%>' />
                    </td>
                </tr> 
                
                <tr>
                    <th class="dataLabel" scope="row" style="text-align:right;">                    
                            Payment Reason Type Id                  
                    </th>
                    <td class="dataCell" style="text-align:left;">
                        <asp:Label ID="lblPaymentReasonTypeId" runat="server" 
                            Text='<%# Eval("PaymentReasonTypeId", "{0:f0}")%>' />
                    </td>
                </tr> 
                
        
                <tr>
                    <th class="dataLabel" scope="row" style="text-align:right;">                    
                            Payment Amount                  
                    </th>
                    <td class="dataCell" style="text-align:left;">
                        <asp:Label ID="lblPaymentAmount" runat="server" 
                            Text='<%# Eval("PaymentAmount", "{0:c}")%>' />
                    </td>
                </tr> 
                
                <tr>
                    <th class="dataLabel" scope="row" style="text-align:right;">                    
                            Transaction Code                    
                    </th>
                    <td class="dataCell" style="text-align:left;">
                        <asp:Label ID="lblTransactionCode" runat="server" 
                            Text='<%# Eval("TransactionCode")%>' />
                    </td>
                </tr> 
                
                <tr>
                    <th class="dataLabel" scope="row" style="text-align:right;">                    
                            Payment Date                    
                    </th>
                    <td class="dataCell" style="text-align:left;">
                        <asp:Label ID="lblPaymentDate" runat="server" 
                            Text='<%# Eval("PaymentDate", "{0:MMM-dd-yyyy}")%>' />
                    </td>
                </tr> 
                
                
                <tr>
                    <td>
                        &nbsp;
                    </td>
                    <td style="text-align:left;">
                                
                                                
                        <des:LinkButton ID="btnEdit" runat="server" 
                            CausesValidation="False" 
                            CommandName="Edit"
                            Text="Edit" />
                    
                        <des:LinkButton ID="btnHideDetails" runat="server" 
                            CausesValidation="False" 
                            CommandName="Cancel"
                            OnClick="btnHideDetails_Click"                      
                            Text="Hide details" />                                      
                    
                        <des:LinkButton ID="btnAdd" runat="server" 
                            CausesValidation="False" 
                            CommandName="New"
                            Text="New" />                                       
                    
                        <des:LinkButton ID="btnDelete" runat="server" 
                            CausesValidation="False" 
                            CommandName="Delete"
                            OnClientClick="return confirm('Do you really want to delete this record?');"
                            Text="Delete" />
                                                                        
            
                    </td>                   
                </tr>
                        
            </table>
        
        </ItemTemplate>
        
    
    

        protected void dsDetail_PerformSelect(object sender, PerformSelectEventArgs2 e)
        {

            PrefetchPath2 prefetch = new PrefetchPath2((int)EntityType.ProductPartnerPaymentEntity);
            prefetch.Add(ProductPartnerPaymentEntity.PrefetchPathPaymentMethod);
            prefetch.Add(ProductPartnerPaymentEntity.PrefetchPathPaymentReasonType);
            dsDetail.PrefetchPathToUse = prefetch;

            using (DataAccessAdapter adapter = new DataAccessAdapter())
            {
                adapter.FetchEntityCollection(e.ContainedCollection, e.Filter, 0, e.Sorter, prefetch);
            }
        }

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 14-Jul-2009 04:53:42   

The entity name and the field name are both the same (PaymentMethodType). I don't know if that is what is causing the problem or not.

You are binding directly to PaymentMethodType. Is that field a field on the PaymentMethodTypeEntity or is a field mapped on related field? Or is a custom property on the ProductPartnerPaymentEntity?

If you don't have the field mapped on related fields on the ProductPartnerPaymentEntity or if you don't have a custom property on ProductPartnerPaymentEntity that returns that related field, I think you should try do this:

Text='<%# Eval("PaymentMethodType. PaymentMethodType")%>'
David Elizondo | LLBLGen Support Team