【发布时间】:2013-05-16 16:09:00
【问题描述】:
我有 3 个表格、产品、productspercategory 和 category。 您可以选择一个类别,然后您会列出该类别中的所有产品。
但我似乎无法让它发挥作用。
我正在使用实体框架,我创建了 2 个实体数据源,一个用于产品,一个用于产品类别。我已经从代码中的变量中的类别中获得了 ID。
我在 productspercategory entitydatasource 中添加了 where 参数。
<WhereParameters>
<asp:ControlParameter ControlID="categoryID" Name="category_id" PropertyName="Value" />
</WhereParameters>
但现在我需要向 products 实体数据源添加 where 参数,以仅显示 productspercategory 实体数据源中的产品。 我该怎么做?
数据库结构:
Category 表包含:name、categoryID Productspercategory 表包含:id、categoryID、productID 产品表包含:productID、name
所以我想获取实体数据源中属于所选 categoryID 的所有产品名称
【问题讨论】:
标签: c# sql entity-framework ado.net where-clause