LINQ选择语法VB.NET [英] LINQ Select Syntax VB.NET
问题描述
我有一个 Tuples
列表,我正在尝试执行 Select
和 Where
查询以返回 Objects列表
来自 Tuple.Item5
参数.在我的where子句中,我希望将 Tuple.Item4
匹配到局部变量.
I have a list of Tuples
I am trying to run a Select
and Where
query on to return a list of Objects
from the Tuple.Item5
parameter. In my where clause I am looking to match Tuple.Item4
to a local variable.
我不确定选择"部分的VB.NET语法是什么,我只知道c#语法.
I'm not sure what the VB.NET syntax is for the Select portion, I only know the c# syntax.
基本上,我试图从我的元组列表中选择 Tuple.Item5
,其中Tuple.Item4 = sCurID.我不确定应该在选择"部分中输入什么内容,尽管在c#中,我相信它将是 Select(t => t.Item5)
Essentially I am trying to select Tuple.Item5
from my list of tuples where Tuple.Item4 = sCurID. I'm unsure as to what should go in the Select section although in c# I believe it would be Select(t => t.Item5)
这就是我所拥有的:
listObj = listTuples.Select( Unsure What Goes Here ).Where(Function(w) w.Item4 = sCurID)
推荐答案
在C#或VB中应用 Select
后,将元组减小为 Item5
值并且无法访问 Item4
.最后执行 Select
:
Once you apply the Select
in C# or VB, you have reduced the Tuple to the Item5
value and can't access Item4
. Do the Select
last:
Dim listObj = listTuples.Where(Function(t) t.Item4 = sCurId).Select(Function(t) t.Item5)
这篇关于LINQ选择语法VB.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!