在同一个 LinqToXml 查询中写入联系人的电话号码?
我有这个代码。
Dim contact1 As XElement = _
<contacts>
<contact>
<%= From contact In contacts _
Select <name><%= contact.Nom %></name> %>
</contact>
</contacts>
这段代码实际上选择联系人
有2个对象,联系人和电话。联系人可以保存电话号码列表。这里是课程详细信息...
Public Class Contact
Private m_Name As String
Public Property Name() As String
Get
Return m_Name
End Get
Set(ByVal value As String)
m_Name = value
End Set
End Property
Private m_Phones As List(Of Phone)
Public Property Phones() As List(Of Phone)
Get
Return m_Phones
End Get
Set(ByVal value As List(Of Phone))
m_Phones = value
End Set
End Property
End Class
Public Class Phone
Private m_Contact As Contact
Public Property Contact() As Contact
Get
Return m_Contact
End Get
Set(ByVal value As Contact)
m_Contact = value
End Set
End Property
Private m_Number As String
Public Property Number() As String
Get
Return m_Number
End Get
Set(ByVal value As String)
m_Number = value
End Set
End Property
End Class
我如何在每个电话的
之间包含电话?
奖金(+1):如何也包括类型?
谢谢。
I have this code.
Dim contact1 As XElement = _
<contacts>
<contact>
<%= From contact In contacts _
Select <name><%= contact.Nom %></name> %>
</contact>
</contacts>
This code actually select contact
There is 2 objects, contact and phone. The contact can hold a list of phone numbers. Here the class details...
Public Class Contact
Private m_Name As String
Public Property Name() As String
Get
Return m_Name
End Get
Set(ByVal value As String)
m_Name = value
End Set
End Property
Private m_Phones As List(Of Phone)
Public Property Phones() As List(Of Phone)
Get
Return m_Phones
End Get
Set(ByVal value As List(Of Phone))
m_Phones = value
End Set
End Property
End Class
Public Class Phone
Private m_Contact As Contact
Public Property Contact() As Contact
Get
Return m_Contact
End Get
Set(ByVal value As Contact)
m_Contact = value
End Set
End Property
Private m_Number As String
Public Property Number() As String
Get
Return m_Number
End Get
Set(ByVal value As String)
m_Number = value
End Set
End Property
End Class
How do i include phones in this query between <phone type="...">...</phone>
for each of them ?
Bonus (+1) : How to include the type also ?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您还没有清楚地描述您想要什么结果或问题是什么,也许以下代码示例有帮助:
输出是
You haven't clearly described what result you want or what the problem is, perhaps the following code sample helps:
The output is