LinqDataSource WHERE查询-ASP.NET

时间:2019-01-11 22:03:44

标签: asp.net linqdatasource

对于我的项目,我正在使用Visual Studio 2017和SQL Server Express。这是3张桌子:  1. Table_Discount  2. Table_Discount_Organization  3. Table_Organization_Type

表通过ID链接。

在我的.aspx文件中,存在以下代码,可以正常运行...:

<asp:LinqDataSource ID="LinqDataSource3" runat="server" ContextTypeName="_03DEC2018_LINQ.UpdateDiscountDataContext" EntityTypeName="" Select="new (Discount_Descrip, Discount_Amount, Discount_Organization, Discount_Validity)" TableName="Table_Discounts" Where= "Discount_ID == 2">
        </asp:LinqDataSource>

不过,上述Where表达式(“ Discount_ID == 2”)应替换为以下功能(SQL代码):

SELECT Discount_Organization, Discount_Descrip, Discount_Amount
FROM Table_Discount, Table_Discount_Organization, Table_Organization_Type
WHERE Table_Discount.Discount_Organization_ID = Table_Discount_Organization.Discount_Organization_ID AND 
    Table_Discount_Organization.Discount_Organization_Type_ID = Table_Organization_Type.Organization_Type_ID AND
    Table_Organization_Type.Organization_Type_Name = 'Webshop'

我尝试了几件事,但无法解决。 欢迎任何建议,谢谢。

0 个答案:

没有答案