Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LINQ Select Syntax VB.NET

Tags:

vb.net

linq

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.

I'm not sure what the VB.NET syntax is for the Select portion, I only know the c# syntax.

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)

This is what I have:

listObj = listTuples.Select( Unsure What Goes Here ).Where(Function(w) w.Item4 = sCurID)
like image 648
Belgin Fish Avatar asked Aug 02 '17 17:08

Belgin Fish


People also ask

How do I select a query in LINQ?

LINQ query syntax always ends with a Select or Group clause. The Select clause is used to shape the data. You can select the whole object as it is or only some properties of it. In the above example, we selected the each resulted string elements.

Which syntax is used in LINQ?

Most queries in the introductory Language Integrated Query (LINQ) documentation are written by using the LINQ declarative query syntax.

Can I use LINQ in VBA?

Based on the generated module you can now use the classes "clsCCSQL" and "clsCCSQL_Condition" to get a kind of "LINQ" in VBA. After importing these two classes into the own database and after generating the module and import it like described above you should be able to compile your code without error message.

What is LINQ select?

Select query in LINQ Select method is used to select one or more items from collection or list object, here we see some example of linq select statement. variableName. Select(s => s.Name); There are various ways we can select some records or single record from a collection object.


1 Answers

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)
like image 132
NetMage Avatar answered Sep 28 '22 04:09

NetMage