如何使用等同于' SELECT IN'在LINQ

时间:2017-02-23 14:54:22

标签: c# linq

我想使用类似于' SELECT IN' LINQ中的sql语句。

这是我的代码:

    var FindM_IDs = (from m in db.vw_InitialLoad
                               where m.M_ID == searchString
                || m.First_Name == firstName.ToUpper()
                || m.Last_Name == lastName.ToUpper()
                || m.Home_Phone == phoneNumber
                || m.Other_Phone == phoneNumber
                || m.Text_Message_Phone == phoneNumber
                || m.Work_Phone == phoneNumber
                || m.CellularPhone == phoneNumber
                            group m by m.M_ID into g
                            select new { M_ID = g.Key }).ToList();

//接下来在此查询中找到M_ID

IEnumerable<vw_CorrGuid> TData;

            if (!string.IsNullOrEmpty(searchString)
                || !string.IsNullOrEmpty(firstName)
                || !string.IsNullOrEmpty(lastName)
                || !string.IsNullOrEmpty(phoneNumber)
                )
            {


               TData = (from e in db.vw_CorrGuid
                                          where e.M_ID.Contains(FindM_IDs)
                                          select e);



            }

正如您想象的那样,这句话是错误的:where e.Medicaid_ID.Contains(FindMedicaid_IDs)

我已尝试使用Array,但这也是不正确的。您的意见得到了赞赏。

0 个答案:

没有答案