我收到以下错误消息...此提供程序仅支持跳过返回实体或包含所有标识列的投影的有序查询,其中查询是单表(非联接)查询,或者是不同的,除了,相交或联合(不是 Concat)操作。
<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
这是一个经典的一对多场景,一个引擎模型许多引擎规格......gridview 由下拉列表(ddlModels)中的一个键选择驱动。选择一个发动机型号,您将在 gridview 表中获得价格表详细信息。我的 LINQ 查询被隔离在一个名为 DataUtils 的数据访问类中。在 LINQDATASOURCE(lds) 的选择事件中,我将 e.Results 属性分配给初始查询的结果,但最终用户通过 ddlModels 选择的 EngineModel 过滤了它(WHERE)。网格视图仅启用了分页而不是排序。为什么我会收到此错误消息?