This is a migrated thread and some comments may be shown as answers.

No property or field 'RecordID' exists in type 'EntityDataSourceWrapper'

8 Answers 455 Views
Grid
This is a migrated thread and some comments may be shown as answers.
kencox
Top achievements
Rank 1
kencox asked on 07 Aug 2009, 09:01 PM

I'm using an EntityDataSource with the RadGrid. Everything was working fine until I added a GridCalculatedColumn. Suddenly, I'm getting this error:

No property or field 'RecordID' exists in type 'EntityDataSourceWrapper'

As you see in the markup at the end of the message, I'm declaring the EntityDataSource declaratively. I encountered a similar problem with the EntityDataSourceWrapper previously in the code behind  and managed to find a fix that I posted here:
 
http://weblogs.asp.net/kencox/archive/2009/07/16/fixing-entitydatasourcewrapper-error-in-ef-vb-version.aspx

Does anyone know a workaround for this when using the EntityDataSource declaratively?

Ken

        <telerik:RadGrid ID="RadGridSalesDetail" runat="server" AutoGenerateDeleteColumn="True" 
            AutoGenerateEditColumn="True" AllowAutomaticUpdates="True" AllowAutomaticDeletes="True" 
            AllowAutomaticInserts="True" DataSourceID="EntityDataSource1" GridLines="None">  
            <MasterTableView AutoGenerateColumns="False" DataKeyNames="RecordID" DataSourceID="EntityDataSource1">  
                <RowIndicatorColumn> 
                    <HeaderStyle Width="20px"></HeaderStyle> 
                </RowIndicatorColumn> 
                <ExpandCollapseColumn> 
                    <HeaderStyle Width="20px"></HeaderStyle> 
                </ExpandCollapseColumn> 
                <Columns> 
                    <telerik:GridBoundColumn DataField="RecordID" DataType="System.Int32" HeaderText="RecordID" 
                        ReadOnly="True" SortExpression="RecordID" UniqueName="RecordID">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridDropDownColumn DataField="PartNumber" DataSourceID="edsPartNumberLookup" 
                        HeaderText="Part Number" ListTextField="PartNumber" ListValueField="PartNumber" 
                        UniqueName="DetailPartNumber" ColumnEditorID="GridDropDownColumnEditor1">  
                    </telerik:GridDropDownColumn> 
                    <telerik:GridNumericColumn DataField="Qty" HeaderText="Quantity" DataType="System.Int32" 
                        UniqueName="DetailQty" ColumnEditorID="GridNumericColumnEditor1">  
                    </telerik:GridNumericColumn> 
                    <telerik:GridBoundColumn DataField="SoldPrice" DataType="System.Double" HeaderText="SoldPrice" 
                        SortExpression="SoldPrice" UniqueName="SoldPrice">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridCalculatedColumn HeaderText="Total Price" UniqueName="TotalPrice" DataType="System.Double" 
                        DataFields="Qty, SoldPrice" Expression="{0}*{1}" FooterText="Total : " Aggregate="Sum" /> 
                </Columns> 
            </MasterTableView> 
        </telerik:RadGrid> 
        <telerik:GridDropDownListColumnEditor ID="GridDropDownColumnEditor1" runat="server" 
            DropDownStyle-Width="110px" /> 
        <telerik:GridNumericColumnEditor ID="GridNumericColumnEditor1" runat="server" NumericTextBox-Width="40px" /> 
    </div> 
    <asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=OfficeBookDBEntities1" 
        DefaultContainerName="OfficeBookDBEntities1" EntitySetName="CMS_SaleDetail" EnableDelete="True" 
        EnableInsert="True" EnableUpdate="True"  EntityTypeFilter="CMS_SaleDetail">  
    </asp:EntityDataSource> 

8 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 11 Aug 2009, 03:43 PM
Hello Ken,

In scenarios where you have EnableLinqExpressions for the RadGrid control set to true and at the same time you are binding the grid to an IEnumerable which is an entity class returned by a O/R Mapper and not containing the actual object's properties, you need to set the RetrieveDataTypeFromFirstItem property of the matster-tableview to true.

Do give this suggestion a try and let us know if further questions arise.

Regards,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
kencox
Top achievements
Rank 1
answered on 11 Aug 2009, 06:18 PM
Hi Tsvetoslav,

Thanks for your response.
 
I tried your suggestion but there was no change. The same error message appears.

I guess what we need (when someone gets a chance) is to create an example project that uses hierarchical databinding against the Entity Framework. That would help me narrow down the issue.

Thanks again,

Ken
Microsoft MVP [ASP.NET]
ASPInsider
Author: ASP.NET 3.5 For Dummies
0
Tsvetoslav
Telerik team
answered on 13 Aug 2009, 12:50 PM
Hello Ken,

Please, find attached a small sample that demonstrates RadGrid's hierarchy with an EntityDataSource and a calculated column in the master table view. In addition, you need to build the project with the latest internal build of the control. In previous versions there have been some issues that have already been fixed.

I hope this helps.

Regards,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
kencox
Top achievements
Rank 1
answered on 17 Aug 2009, 11:33 PM
Hi Tsvetoslav,

I tried your code with Telerik.Web.UI_2009_2_810_dev_hotfix and had the same 'EntityDataSourceWrapper' issue.

Perhaps you have a later internal version of the DLL than the one that has been made public?

Could you make it available?

Ken
0
Tsvetoslav
Telerik team
answered on 18 Aug 2009, 01:10 PM
Hi Ken Cox,

You are correct. I have done the mistake of testing the scenario under .NET 2.0 where everything is bound to work since no linq expressions are used internally by the grid. 

The reality is that whenever there are subobjects (as in the case of entity types related to each other which is necessary for a hierarchical grid) and at the same time calculated columns in the grid, the EnableLinqExpressions property should be set to false. Otherwise, there is no way in which a proper linq query containing foreign key columns can be parsed by the dynamic linq parsing framework used by the grid.

Greetings,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
kencox
Top achievements
Rank 1
answered on 24 Aug 2009, 05:01 PM
Is there a workaround that would allow me to have calculated values in the footers while still using Entity Framework?
0
Tsvetoslav
Telerik team
answered on 26 Aug 2009, 11:53 AM
Hello Ken Cox,

Just set the EnableLinqExpressions for the grid to false.

I hope this information helps.

Best wishes,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Chun
Top achievements
Rank 1
answered on 30 May 2012, 05:19 PM
This worked for me.  Thanks for the post.
Tags
Grid
Asked by
kencox
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
kencox
Top achievements
Rank 1
Chun
Top achievements
Rank 1
Share this question
or