我需要简单的LINQ查询,这将创造字典 我对XML其中包含可以作为免费 以下的客户,谁可以买一些产品 为每一位客户只有一个产品的名单是我的示例XML 我已经装箱的一类,看起来像LINQ查询创建词典
Public Class CustomerFreeItem
{
public string CustomerID
public string FreeproductName
public string ActualPrice
}
<customers>
<customer id="1">
<product name="book" free="false" actualPrice="10"/>
<product name="pen" free="true" actualPrice="10"/>
<product name="scale" free="false" actualPrice="10"/>
</customer>
<customer id="2">
<product name="book" free="true" actualPrice="10"/>
<product name="pen" free="false" actualPrice="10"/>
<product name="scale" free="false" actualPrice="10"/>
</customer>
<customer id="3">
<product name="book" free="false" actualPrice="10"/>
<product name="pen" free="false" actualPrice="10"/>
<product name="scale" free="true" actualPrice="10"/>
</customer>
</customers>
弗罗姆以上的XML我想有一个字典客户ID作为键和值FreeProduct(CustomerFreeItem对象)
请建议
谢谢, 鲑鱼。
你自己的方法在哪里? – KroaX
它是'vb.net'还是'c#'?我认为它是你的类声明中的'vb'。每个客户都有免费产品吗?是否只有一种免费产品,或者一个客户可能有更多免费产品? –