【发布时间】:2009-05-04 18:43:47
【问题描述】:
我有以下三个表:
alt text http://img16.imageshack.us/img16/5499/linqtosqlquery.jpg
使用 LinqToSql,我想检索 InventoryItems 列表,其中 (pointsName="Level" AND pointsValue
请注意,maxStoreLevel 是一个整数,它是 pointsName = "Level" 的点行的值。
由于您不能在 Linq 中的另一个 where 中使用 where,我不知道如何检索提到的列表。
更新:这是根据要求提供的 UML 图
alt text http://img17.imageshack.us/img17/3403/umldiagram.jpg
为了进一步解释我的场景,这里是我表中的数据:
alt text http://img4.imageshack.us/img4/7847/linqexample.jpg
假设 maxStoreLevel 为 1,“Hanzo's Helmet”的 pointsValue = 1 其中 pointsName="Level" 并且还有一个名为“Buy Price”的点,因此应该返回它的行(与具有相同条件的任何其他 Inventoryitems 相同)
【问题讨论】:
-
你定义了外键吗?能发个dbml图吗?
-
我正在研究一个示例,但我需要对标准进行一些澄清...您说“其中 pointsName="Level", pointsName="Buy Price" 和 pointsValue = maxStoreLevel"。这是 (pointsName="Level" OR pointsName = "Buy Price") AND pointsValue = maxStoreLevel ... 还是 pointsName = "Level" OR (pointsName="Buy Price" AND pointsValue = maxStoreLevel)。此外,在 maxStoreLevel 上,是否只有一行 pointsName = "Level" 或者每个 InventoryItem 一行?我们可以假设每个 InventoryItem 都有一个具有该值的点吗?
标签: c# linq linq-to-sql