I have the following mapped in my Entity Data Model to my Database
Products
ProductName
CreatedDate
UpdatedDate
...
I then created a partial class, which gives an additional property to Products
public partial class Product
{
public DateTime LatestDate
{
get
{
if(UpdateDate.HasValue) return UpdateDate.Value;
return CreatedDate;
}
}
}
I then did the following:
<asp:EntityDataSource ID="EntityDataSource1" runat="server"
ConnectionString="name=TwModelContainer"
DefaultContainerName="TwModelContainer" EnableFlattening="false"
EntitySetName="Products">
</asp:EntityDataSource>
<telerik
:RadGrid ID="RadGrid1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" DataSourceID="EntityDataSource1"
GridLines="None" onitemcreated="RadGrid1_ItemCreated" AllowSorting="True">
<
MasterTableView DataSourceID="EntityDataSource1" DataKeyNames="Id">
<
telerik:GridSortExpression FieldName="LastDate" SortOrder="Descending" />
Unfortunately, this does not work. I can easily show the created field LastDate in the Grid, but sorting won't work. It gives me the following error:
'LastDate' is not a member of type 'TwModel.Product' in the currently loaded schemas. Near simple identifier, line 6, column 4
I guess in means that sorting works only for what is availabe in the database schema, but how would I accomplish the above with an additional calculated property, i.e. LastDate?