-
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
Anonymous type to value tuple casting #22889
Comments
I'm sorry, I didn't understand the issue. |
@mojtabakaviani I think this is a duplicate of #12897 as you mentioned. The example you gave wouldn't be possible without #12897 (and the corresponding feature in EF (or any other LINQ provider)). |
Yes, anonymous types just access in definition block and can not use in deferent code block. #12897 issue is expression trees not support for tuples, but in want can cast anonymous type to tuples. var news1 = from n in db.News
select new { n.Id, n.Title, CreatedBy = n.User.Name };
//casting anonymous to tuple
var news2 = news1 as IEnumerable<(int Id, string Title, string CreatedBy)>; in this simple casting anonymous to tuples and can send to other code block. |
no type equivalency is defined between a value type and anonymous types. even if we had support for duck typing, that wouldn't work because tuple names are not present in the type itself, (just as metadata). |
With many improvments for value tuple type, now if can casting anonymous type to tuple. a big change in MVC when pass model to view. for example:
return model:
in view:
but before is must solved #12897
The text was updated successfully, but these errors were encountered: