Linq to sql 我能';在Linq to SQL中进行筛选时,无法获得适当的结果
我有下面编译的Linq到SQL代码,但是为什么变量Linq to sql 我能';在Linq to SQL中进行筛选时,无法获得适当的结果,linq-to-sql,Linq To Sql,我有下面编译的Linq到SQL代码,但是为什么变量products没有填充 NorthwindDataContext ndc= new NorthwindDataContext(); var countries= new []{"Uk", "France" ," Germany"}; var productCountries = from product in ndc.Products join supplier in ndc.Supplie
products
没有填充
NorthwindDataContext ndc= new NorthwindDataContext();
var countries= new []{"Uk", "France" ," Germany"};
var productCountries = from product in ndc.Products
join supplier in ndc.Suppliers
on product.SupplierID equals supplier.SupplierID
select new {Product=product, Country= supplier.Country};
var products = from productCountry in productCountries
where countries.Contains(productCountry.Country)
select productCountry.Product;
我想这是因为我必须首先使用foreach获取productCountries
,我尝试过这样做,将我在productCountries
中使用的查询结果插入到产品的键入列表中,但这不起作用
您能帮我了解一下如何填写产品吗 首先,对于查询,请使用SQL Profiler
同样关于查询
where countries.Contains(productCountry.Country)
看来这是不对的
我还没有运行它,但看看查询,它看起来是这样的。
您需要将where条件放在表的列上,而不是放在数组列表上