I am getting the following error message…
This provider supports Skip only over ordered queries returning entities or projections that contain all identity columns, where the query is a single-table (non-join) query, or is a Distinct, Except, Intersect, or Union (not Concat) operation.
<asp:DropDownList ID="ddlModels" runat="server"
DataSourceID="ldsListOfModelNos"
DataTextField="EngineModel"
DataValueField="EngineModel"
AppendDataBoundItems="True"
AutoPostBack="true">
</asp:DropDownList>
<br/>
<br />
<asp:LinqDataSource ID="ldsListOfModelNos"
runat="server" >
</asp:LinqDataSource>
<asp:GridView ID="gvPriceListByModel" runat="server" EmptyDataText="No Price Info Available" AutoGenerateColumns="False" CellPadding="4" CellSpacing="4" ForeColor="#333333" GridLines="None" AllowPaging="True" DataSourceID="ldsPBM2" DataKeyNames="EngineSpec">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:BoundField DataField="EngineModel" HeaderText="EngineModel"
Visible="False" />
<asp:BoundField DataField="EngineSpec" HeaderText="ItemNo" />
<asp:BoundField DataField="NewOrRebuilt" HeaderText="NR" Visible="False" />
<asp:BoundField ConvertEmptyStringToNull="False" DataField="RetailPrice"
DataFormatString="{0:c}" HeaderText="Retail Price" />
<asp:BoundField DataField="DistributorPrice" DataFormatString="{0:c}"
HeaderText="Distributor Price" />
<asp:BoundField DataField="CorePrice" DataFormatString="{0:c}"
HeaderText="Core Price" />
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
Protected Sub ldsPriceListByModel2_Selecting(sender As Object, e As System.Web.UI.WebControls.LinqDataSourceSelectEventArgs) Handles ldsPriceListByModel2.Selecting
If Not IsPostBack Then
Dim sd As SessionData = Session("SessionData")
sd.CmpCode = "95102"
Dim cmpCode = sd.CmpCode
Dim interimResult = dataUtil.GetQueryablePriceList(cmpCode)
e.Result = interimResult.Where(Function(m) m.EngineModel = ddlModels.SelectedValue).OrderBy(Function(o) o.EngineSpec)
End If
End Sub
Public Class DataUtils
Private dc As DataAccess
Public Function GetQueryablePriceList(cmpCode As String) As IQueryable(Of PriceInfo)
dc = New DataAccessClass(ConfigurationManager.ConnectionStrings("xxx").ConnectionString.ToString())
Dim PriceListQuery = (From ms In dc.dbo.v_ModelSpecs
Join pl In dc.dbo.v_pricelists
On ms.item_no Equals pl.item_no
Join ci In dc.dbo.cxabcx_VWs
On pl.accounttypecode Equals ci.AccountTypeCode
Where (pl.price <> 0 And ci.cmp_code = cmpCode)
Select New PriceInfo() With {.EngineModel = ms.Model,
.EngineSpec = ms.item_no,
.NewOrRebuilt = IIf(pl.item_desc_1 = "ENGINE - NEW", "N", "R"),
.RetailPrice = pl.price, .DistributorPrice = pl.disc_price, .CorePrice = pl.sls_price}).AsQueryable()
Return PriceListQuery
End Function
Public Class PriceInfo
Public Sub New()
End Sub
Public Property EngineModel As String
Public Property EngineSpec As String
Public Property NewOrRebuilt As Char
Public Property RetailPrice As Decimal
Public Property DistributorPrice As Decimal
Public Property CorePrice As Decimal
End Class
This is a classic one to many scenario, one engine model many engine specs…gridview driven by a key selection from a dropdownlist(ddlModels). Pick an engine model, you get price list details in a gridview table. My LINQ queries are isolated in a data access class called DataUtils. In the selecting event for the LINQDATASOURCE(lds) I assign the e.Results property to the result of the initial query but having filtered it(WHERE) by the EngineModel selected by the end-user via ddlModels. The gridview only has Pagin enabled NOT SORTING. Why would I be getting this error message?
Short answer is it appears you have run into a limitation of the linqdatasource object. You may need to try manually binding and not using the datasource. I regularly avoid the LinqDataSource in most cases unless I’m just dealing with a simple flat table mapping.
Alternatively, you could try adding the attribute to the columns in the PriceInfo object’s definition, but this option is untested.
You may want to check out the suggestions in various forum postings from this search: http://www.bing.com/search?q=%22This+provider+supports+Skip+only+over+ordered+queries+returning+entities+or+projections+that+contain+all+identity+columns%22&qs=n&form=QBRE&pq=%22this+provider+supports+skip+only+over+ordered+queries+returning+entities+or+projections+that+contain+all+identity+columns%22&sc=0-0&sp=-1&sk=