如何将满足哪个 OR 条件添加到我的结果中
在下面的 LINQ 查询中,我返回满足某些条件的人员。在标准中,我有一个 OR 条件。如何返回此人满足了哪些 OR 条件?我想在 .Select 语句中包含 x.AttId。每个人可以同时分配多个 AttId。
var DNR = dc.Contacts.Where(x => x.Type == 1 &&
x.Att.Any(caa =>
caa.ContactID == x.ContactID &&
( caa.AttID == 102 || caa.AttID == 103 )
)
)
.Select(x => new {x.ContactID, x.FirstName, x.LastName})
.OrderBy (x => x.ContactID)
In the following LINQ query I'm returning people that meet some criteria. In the criteria, I have an OR condition. How do I return which of the OR conditions the person met? I'd like to include a x.AttId in the .Select statement. Each person can have many AttIds assigned to them at the same time.
var DNR = dc.Contacts.Where(x => x.Type == 1 &&
x.Att.Any(caa =>
caa.ContactID == x.ContactID &&
( caa.AttID == 102 || caa.AttID == 103 )
)
)
.Select(x => new {x.ContactID, x.FirstName, x.LastName})
.OrderBy (x => x.ContactID)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以执行以下操作:
You can do the following:
如果您想知道匹配的
AttID
的不同集合,可以选择以下选项。Here's an option if you wish to know the distinct set of
AttID
that match.