LinqDataSource Where Parameter

2019-08-23 22:54发布

问题:

I have the below query on my aspx page that works:

<asp:LinqDataSource ID="LinqDataSource1" runat="server" 
    ContextTypeName="InventoryDataContext" 
    EntityTypeName="" TableName="V_InventoryForDisplays" 
    Where="ConfiguredCarId == @ConfiguredCarId">
    <WhereParameters>
        <asp:Parameter DefaultValue="2827" Name="ConfiguredCarId" Type="Int32" />
    </WhereParameters>
</asp:LinqDataSource>

I need to change the Where clause to use a Contains statement. I have an auto-propertyЖ

public IEnumerable<int> ConfiguredCarIds { get; set; }

within the same class that I would like to use

so what is the proper syntax to do this:

Where="ConfiguredCarIds.Contains (ConfiguredCarId)"

Thanks!

回答1:

Try Where="ConfiguredCarId.Contains(@ConfiguredCarId)"