0
我有两个表代表混合物和混合物的组成部分。该表的布局是这样的:LINQ到SQL子选择
Mixture table:
MixtureID uniqueidentifier
MixtureDescription varchar(50)
Components table:
ComponentID uniqueidentifier
MixtureID uniqueidentifier (FK to previous table)
ComponentName varchar(50)
ComponentRatioPercentage int
现在,我想要做的就是采取从用户输入组件名称的列表,找到包含所有这些组件的任何混合物的ID的。
在SQL我会这么像:
select distinct MixtureID
from Mixture Mixture
where exists (select ComponentName
from Components Components1
where Components1.MixtureID = Mixture.MixtureID and
Components1.ComponentDescription = 'SomeComponentName')
and exists (select ComponentName
from Components2
where Components2.MixtureID = Mixture.MixtureID and
Components2.ComponentDescription = 'SomeOtherComponentName')
and exists....
等,增添一分选的每个组件。
我该怎么做这样的linq到sql?在用户完成输入之前,要预先查找的组件数量不会被预先知道,尽管最多可以有10个。预先感谢!
你尝试过什么吗?如果是这样,发布它,我们可以更好地帮助你。 – 2012-03-26 22:37:41