-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Use (value) tuples for query translation #8192
Comments
I like the idea. |
Would this apply only to delegate-based providers (like |
@svick I hope not. If expression trees going to support tuples, I think it still can be done for |
@alrz I don't understand, how could you make this change backwards compatible? For example if you have (nonsensical) query like: from foo in fooSource
let bar = foo.Bar
select bar Then currently the generated code is: fooSource.Select(foo => new { foo = foo, bar = foo.Bar})
.Select(transparentIdentifier => transparentIdentifier.bar) With this proposal, the generated code would be: fooSource.Select(foo => (foo: foo, bar: foo.Bar))
.Select(transparentIdentifier => transparentIdentifier.bar) But current LINQ providers expect the former pattern and I think it's very likely many of them wouldn't work with the latter pattern, at least not without modification. |
I doubt we would change the way we translate to expression trees. That would not make anybody's life easier. |
@alrz I'm not saying it can't be done, I'm saying it's likely that existing providers wouldn't understand it. In other words, I'm not concerned about creating the expression tree, I'm concerned about reading it. What I'm saying is that I expect that at least some providers expect anonymous types. And if they see something else, they will not work properly. But I have no idea how common this issue would be. |
I think this is a marvellous idea. I just proposed something very similar to it in the C# language repo. It has the potential to be a big win for performance and could go some of the way to undoing LINQ's reputation for being slow. My only bit of feedback is that it might be worth considering making this behaviour optional, perhaps using a method-level attribute as I outlined in the linked issue. (I have no opinion as to whether it should be opt-in or opt-out.) It's not always desirable to use a struct - when they are large they can be expensive to copy around. This would also simplify the question of how to implement the translation for query providers that use |
If we add Tuples (#347), we could use them in the translation of linq queries instead of anonymous types.
/cc @VSadov @jaredpar
The text was updated successfully, but these errors were encountered: