LINQ 中有 3 个 where 子句
我在 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,..});
我在这里做错了什么?
问候, 巴维克
I have 3 where clauses in LINQ, but its failing - I tried this
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, ...});
I also tried to have 2 joins -
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,..});
What am i doing wrong here?
Regards,
Bhavik
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个。我用“and”更改了“where”
,您需要指定公司和角色的ID:
Try this. I changed the "where" with an "and"
And you need to specify the id of the companies and roles: