我想在linq中使用OR從同一列中搜索多個值。在SQL中,它是這樣的:var query = "Select * from table where id = 1";query += "OR where id = 2";id來自id數(shù)組,因此我將id傳遞給變量并循環(huán)。數(shù)組中ID的數(shù)量不是固定的,它取決于用戶通過選中表中的復(fù)選框選擇的ID數(shù)量。因為如果我按以下方式進行操作,則它將返回null,因為它在某種程度上將我的where查詢解釋為AND。我如何更改它,以便它將從所有ID(使用OR)獲取行?Request request = db.Requests;var selectedIdList = new List<string>(arrId);if (arrId.Length > 0){ for (var item = 0; item <= selectedIdList.Count() - 1; item++) { var detailId = Convert.ToInt32(selectedIdList[item]); request = request.Where(y => y.Id == detailId); }}
- 2 回答
- 0 關(guān)注
- 220 瀏覽
添加回答
舉報
0/150
提交
取消