Afternoon,
I am passing in a bool value from a text box, and i need to check to see if its true or false then add the correct codetype (int) for it to search by.
for example
if (hasASIN == true)
{
int show = 5;
}
else {
int show = 1, 2, 3, 4 (these are the other code types)
}
i then would need to add a where clause to my LINQ statement.
where a.codeType == show (need to have this maybe in a || (or) bit so i can use the other code types)
below is my existing LINQ Code
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();
I hope i have explained this ok, if not feel free to ask away 🙂 Thanks in advance.
After much search i found the answer which worked a treat…