dotnet / dotnet/vblang

[Proposal] LinQ with a multiple collections result

Open
#565 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
328
Forks
71
PR merge metrics
No merged PRs in 30d

Description

I want to use one LinQ querty to obtain more than one list in the result (which is better performance than iterating the collection many times to get a single list at a time).
I suggest to allow using multiple Select clauses in the query (gives an error currently):

```
Dim result = From s In Students
Select s.ID
Select s.Name
```

Which can be lowered to:
```
Dim ids As New List(Of Integer)
Dim names As New List(Of String)

For Each s In Students
ids.Add(s.ID)
names.Add(s.Name)
Next
result = New With {.IDs = ids, .Names = names}
```

Note: using the #564 proposal, the suggested syntax can be rewritten as:
```
Dim result = From Students
Select ID
Select Name
```

I also suggest to alow us to choose another collection type (other the default `List(Of T)`):
```
From Student
Select Id
Select Name As ObservableCollection(Of String)
```

Which can be lowered to:
```
Dim ids As New List(Of Integer)
Dim names As New ObservableCollection(Of String)

For Each s In Students
ids.Add(s.ID)
names.Add(s.Name)
Next
result = New With {.IDs = ids, .Names = names}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.