下午,我从一个文本框中传入一个 bool 值,我需要检查它是真还是假,然后添加正确的代码类型 (int) 以供搜索。
例如
if (hasASIN == true)
{
    int show = 5;
}
else {
    int show = 1, 2, 3, 4 (these are the other code types)
}
然后我需要在我的 LINQ 语句中添加一个 where 子句。
where a.codeType == show (need to have this maybe in a || (or) bit so i can use the other code types)
下面是我现有的 LINQ 代码
 var query = from a in dc.aboProducts
             join t in dc.tweProducts on a.sku equals t.sku
             where (string.IsNullOrEmpty(productSku) || productSku == t.sku)
             where (string.IsNullOrEmpty(productAsin) || productAsin == a.asin)
             where (string.IsNullOrEmpty(productName) || t.title.Contains(productName))
             where (string.IsNullOrEmpty(productBrand) || t.brand.Contains(productBrand))
             where a.amzPrice >= priceFrom && a.amzPrice <= (priceTo)
             where a.amzLive == isLive 
             select new GetProducts
             {
                productid = Convert.ToInt32(t.id),
                sku = t.sku,
                title = t.title,
                tweprice = Convert.ToString(t.twePrice),
                stock = Convert.ToInt32(t.stock),
                asin = a.asin,
                amzprice = Convert.ToString(a.amzPrice),
                amzlive = Convert.ToBoolean(a.amzLive),
                lastupdated = Convert.ToDateTime(t.lastUpdated)
             };
  return query.ToList();
我希望我已经解释过了,如果不能随意询问:) 提前谢谢。