vb.net - vb.net linq 查询多个信息
问题描述
我有一个数据表 treno1,其中包含 10 个关于团体铁路预订的列。我需要知道一些信息:从每辆旅行车的城市所有目的地我从网上获得 json 预订。
With treno1
.Columns.Add("Departure", System.Type.GetType("System.String"))
.Columns.Add("Arrival", System.Type.GetType("System.String"))
.Columns.Add("PNR", System.Type.GetType("System.String"))
.Columns.Add("Level", System.Type.GetType("System.String"))
.Columns.Add("Last Name", System.Type.GetType("System.String"))
.Columns.Add("Car", System.Type.GetType("System.String"))
.Columns.Add("seat", System.Type.GetType("System.String"))
.Columns.Add("first name", System.Type.GetType("System.String"))
.Columns.Add("Train", System.Type.GetType("System.String"))
.Columns.Add("ID res", System.Type.GetType("System.String"))
End With
For Each item As JProperty In data
item.CreateReader()
For Each msg As JObject In item.Values
treno1.Rows.Add(msg("departureLocationName"), msg("arrivalLocationName"), msg("pnrCode"), msg("serviceLevel"), msg("lastName"), msg("wagon"), msg("seat"), msg("firstName"), msg("transportMeanName"), msg("Id"))
Next
Next`
在这里我得到了一些信息
Dim destinations = From n In table1.AsEnumerable()
Where n.Field(Of String)("Departure") = ComboBox1.SelectedValue
Select n.Field(Of String)("Arrival")
Dim wagons = From n In table1.AsEnumerable()
Where n.Field(Of String)("Departure") = ComboBox1.SelectedValue
Select n.Field(Of String)("wagon")
Dim wagonlist = (wagons.Distinct).ToList
Dim destinations = (destination.Distinct).ToList
现在得到:货车号码目的地和该目的地的人怎么可能是查询?例如:从罗马(combobox1.selectevalue)货车 1 - 10 人登机 - 5 佛罗伦萨,3 博洛尼亚 - 2 米兰货车 2 - 14 人登机 - 5 佛罗伦萨,3 博洛尼亚 - 2 米兰,4 皮亚琴察等...怎么可能查询
我做了这个,但它没有做出正确的输出。
For Each value In wagonlist
Dim destinazioneglobale = From n In treno1.AsEnumerable()
Where n.Field(Of String)("Departure") = ComboBox1.SelectedValue And n.Field(Of String)("Wagon") = value
Select n.Field(Of String)("Arrival")
For Each element In destinazioneglobale
Dim count4 = treno1.AsEnumerable().Count(Function(row) (row.Field(Of String)("Departure") = ComboBox1.SelectedValue) And (row.Field(Of String)("Arrival") = element))
ListBox11.Items.Add(value.ToString & (element.ToString))
Next
Next
解决方案
推荐阅读
- python - 使用漂亮的汤抓取 youtube 搜索结果的问题
- class - 活动元素上的Vue自定义无线电组件类
- python - 如何可视化多元多项式回归的回归线?
- excel - 宏将数据从 Access 传输到 Excel 我面临问题
- laravel - 如何添加/覆盖 SessionGurad?
- c# - 在向数据库添加新实体时上下文不填充外键
- java - 将表达式反转为 Java 中的波兰表示法
- python - 使用列表范围执行循环
- sql - 使用 Tfs_Warehouse.dbo.FactCurrentWorkItem,如何从 Query 中获取请求和项目名称?
- python - 找不到 python 解释器时,Ansible play 挂起