在LINQ中有3个where子句

时间:2012-01-18 11:58:39

标签: c# linq entity-framework-4 linq-to-entities

我在LINQ中有3个where子句,但它失败了 - 我试过这个

List<string> companies = new List<string>() { "0001001429"};
List<string> roleIDs = new List<string>() { "1486334", "1419282"};


var q = (from up in UserReports
        where up.UserType == "Internal"     
        where companies.Contains(up.CompanyId) && roleIDs.Contains(up.RoleId)
                             select new 
                             {
                                 UserId = up.UserId,
                                 FirstName = up.FirstName,
                                 LastName = up.LastName, ...});

我也尝试过2个连接 -

var q = (from up in UserReports
                             join c in companies on up.CompanyID equals c
                             join r in rolesIDs on up.RoleId equals r
                             where up.UserType == "Internal"
                             select new 
                             {
                                 UserId = up.UserId,..});

我在这里做错了什么?

此致 Bhavik

0 个答案:

没有答案