Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LINQ query materialization in-language syntax (ToArray/ToList/Single/Sum etc.) #291

Closed
weitzhandler opened this issue Mar 20, 2017 · 6 comments

Comments

@weitzhandler
Copy link

weitzhandler commented Mar 20, 2017

Hi,

I almost never use C# LINQ when I need a one liner, because then I have to wrap the whole query in parentheses or use a variable:

var query = from u in people
                   where u.Age > 30
                   select u.Name;
var result = query.ToArray();

Or

var result = (from u in people
                    where u.Age > 30
                    select u.Name).ToArray();

Both ways are not so aesthetic.

As suggested in this post, please extend the built-in LINQ features in the language itself to include execution/materialization capabilities.

Here are some other related posts that's worth reading:

Personally I like the first couple most as it's simple, requires no big introduction of new keywords and is flexible. But the first one is also a great point.

@weitzhandler weitzhandler changed the title Please embed ToArray, ToList, Single etc. in the language LINQ query materialization in-language syntax Mar 20, 2017
@weitzhandler weitzhandler changed the title LINQ query materialization in-language syntax LINQ query materialization in-language syntax (ToArray/ToList/Single/Sum etc.) Mar 20, 2017
@alrz
Copy link
Member

alrz commented Mar 20, 2017

Related to this dotnet/roslyn#100 (comment) and somehow #101.

@weitzhandler
Copy link
Author

weitzhandler commented Mar 20, 2017

@alrz
The 100th issue was mentioned in my question, anyway that issue closed in order to be posted here. So that's what I did.
Will refer to 101 as well which is indeed related.

@weitzhandler
Copy link
Author

I'm closing this issue as it was already offered here

@orthoxerox
Copy link

No, please reopen it. #101 is about a different proposal, let's use this one to discuss passing the result to a collector.

@weitzhandler
Copy link
Author

weitzhandler commented Mar 20, 2017

@orthoxerox
See the 3rd comment on that post, as @alrz mentioned here.

@aluanhaddad
Copy link

I would definitely appreciate such a feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants