Need a way that is friendly with required etc. that can do "New Or Update Properties" #7756
Unanswered
JohnGalt1717
asked this question in
Language Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Problem: Right now you end up repeating yourself a lot in scenarios like this:
required as a keyword is great. But it adds even more to the verboseness of this syntax. And this happens all of the time when inserting/updating Dtos and many other cases.
I would like to see something similar to:
This looks very similar to the way you update a record with new values.
What it would do behind the scenes is, if document was null, it would create a new one (in this case with the default constructor but (property1, property2) { ... fields} would also be valid) and assign all of the fields.
If the document existed, it would simply set the properties accordingly.
And of course the "all fields to be updated or set" would be strongly typed with the fields in the type.
Beta Was this translation helpful? Give feedback.
All reactions