【发布时间】:2013-06-24 18:48:49
【问题描述】:
我有以下代码需要修改为group by offer,但我不确定如何在此查询中添加group by 部分。
有什么想法吗?
propertyInfo = myXmlFile.Descendants("offer").Descendants("site") _
.Where(Function(f) _
f.Attributes("code").First.Value = Location.Text) _
.Select(Function(f) New With { _
.LOCATION = f.Attributes("code").First.Value, _
.TITLE = f.Parent.Attributes("title").First.Value, _
.OFFER = f.Parent.Attributes("offerid").First.Value, _
.POPUPDESC = f.Parent.Descendants("short_desc").Value
示例 XML
<offers>
<offer title="Offer title" offerid="AS32">
<short_desc><![CDATA[
<div>Your HTML's body <a href='dfgdfgdfgdfg.html'>Offer title</a>
</div>
]]></short_desc>
<site code="CO">
<year_week_start>201344</year_week_start>
<year_week_end>201414</year_week_end>
</site>
<site code="FH">
<year_week_start>201446</year_week_start>
<year_week_end>201450</year_week_end>
</site>
</offer>
</offers>
【问题讨论】:
-
您真的需要使用 LINQ 方法语法吗?我认为对于像分组查询语法msdn.microsoft.com/en-us/library/bb531412.aspx 这样的任务更容易处理。 XML 的样本会有所帮助。是否要按属性
offerid分组?
标签: asp.net xml vb.net linq-to-xml