LINQ“例外”操作员
我有一个事件 ID 列表,我想将其从 select 语句中排除,但不确定如何实现:
这是存储我的事件 ID 列表的内容
List<int> ExcludedEvents;
,这是我的 select 语句(来自 XML feed),
var allEvents = from eventsList in xmlDoc.Elements("shows").Elements("Show")
select new EventFeed()
{
EventName = eventsList.Attribute("Name").Value,
EventSummary = eventsList.Attribute("ShortDesc").Value,
EventDetails = eventsList.Attribute("LongDesc").Value,
EventShowCode = eventsList.Attribute("Code").Value
};
我想要选择除 eventId 与 EventShowCode 值匹配的事件之外的所有事件
我已经查看了 except 运算符,但不确定如何实现它
i have a list of event Ids that i want to be excluded from my select statement, but no sure how to implement this:
this is what stores my list of event Ids
List<int> ExcludedEvents;
and this is my select statement (from an XML feed)
var allEvents = from eventsList in xmlDoc.Elements("shows").Elements("Show")
select new EventFeed()
{
EventName = eventsList.Attribute("Name").Value,
EventSummary = eventsList.Attribute("ShortDesc").Value,
EventDetails = eventsList.Attribute("LongDesc").Value,
EventShowCode = eventsList.Attribute("Code").Value
};
i want to select all events except for the events that have their eventId matching the EventShowCode value
i have looked at the except operator, but not sure how to implement it
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据您在问题中的代码,它应该看起来像这样...
或者,如果您只是想将其附加到 select 语句的末尾,只需将该Where 放在 Select from 的末尾即可您之前的查询...
based on your code in the question, it should look something like this...
Or, if you just wanted to tack it on to the end of your select statement, just take that Where and drop it right at the end of your Select from your previous query...