【发布时间】:2018-07-04 07:31:26
【问题描述】:
我目前正在构建的模块的要求之一是我需要使用 Linq 选择数据,但 ID 是通过整数数组传递给我的
var CheckedArray = Request["doc_download"];
string[] detailIds = CheckedArray.Split(',');
List<int> dtIds = new List<int>();
foreach (string words in detailIds)
{
dtIds.Add(Int32.Parse(words));
}
using (var ctx = new Connect2020Entities())
{
DetailList = (from userDetail in ctx.DocumentDetail
where userDetail.ID == <!-- items in dtIds --> //<<I do not know what could be used to compare all of the data from the array in a single query>>
select new DetailList()
{
FilePath = userDetail.FilePath
}).ToList<UserDocument>();
}
可以做些什么,以便可以在查询中一次性比较整数数组中的所有 id。我目前想不出一个可行的逻辑来允许将数组中的值用作我正在使用的查询中的参数。
*DocumentDetail字段ID是一个整数。
【问题讨论】: