-3
我有這個搜索代碼。在Where子句中使用if/else lambda表達式
public List<Tbl_Product> ProductSearch(DateTime startdate, DateTime enddate, string productname, int suply)
{
var q = _db.Tbl_Product
.Where(model =>
model.DateReg == startdate &&
model.DateReg == enddate)
.Where(model =>
model.ProductName.Contains(productname))
.Where({});
}
現在我需要在最後Where
插入此代碼。
if(suply == 1)
{
model.Suply > 0 ;
}
else
{
model.Suply = 0;
}
我應該怎麼做?
你爲什麼要使用3倍「在哪裏」? –
beacuse產品名稱或其他fild可以是空的 – Kianoush
嗯。 「Lambada」 –