-
Notifications
You must be signed in to change notification settings - Fork 24
DOCSP-49279: $convert stage LINQ method #604
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
DOCSP-49279: $convert stage LINQ method #604
Conversation
✅ Deploy Preview for docs-csharp ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM w/ a couple quick fixes
source/fundamentals/linq.txt
Outdated
.. code-block:: csharp | ||
|
||
var query = queryableCollection | ||
.Select(r => Mql.Convert(r.RestaurantId, new ConvertOptions<int>())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @papafe would you prefer if we showed a more complex example that uses the options?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the example is fine, it's difficult to make a more complex example using the dataset we have in this page. But at least you can show OnError
or OnNull
. So it could be:
var query = queryableCollection
.Select(r => Mql.Convert(r.RestaurantId, new ConvertOptions<int>( OnError = -1, OnNull = 0 )));
source/fundamentals/linq.txt
Outdated
$convert | ||
~~~~~~~~ | ||
|
||
You can use the ``Mql.Convert()`` method in a ``Select()`` projection to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of Mql.Convert
is not limited only to Select
, even though it could be the most common.
source/fundamentals/linq.txt
Outdated
.. code-block:: csharp | ||
|
||
var query = queryableCollection | ||
.Select(r => Mql.Convert(r.RestaurantId, new ConvertOptions<int>())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the example is fine, it's difficult to make a more complex example using the dataset we have in this page. But at least you can show OnError
or OnNull
. So it could be:
var query = queryableCollection
.Select(r => Mql.Convert(r.RestaurantId, new ConvertOptions<int>( OnError = -1, OnNull = 0 )));
source/fundamentals/linq.txt
Outdated
$convert | ||
~~~~~~~~ | ||
|
||
You can use the ``Mql.Convert()`` method in a ``Select()`` projection to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see from the other operators in the page that usually we first introduce briefly the operator, and then show how to use it in LINQ. Maybe we should follow that pattern?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved some sections around to distinguish between stages/operators
source/fundamentals/linq.txt
Outdated
The ``Convert()`` method takes the following parameters: | ||
|
||
- Value to convert. | ||
- ``ConvertOptions<Tto>`` instance that specifies the type to convert to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we can omit TTo
, as we did not introduce it before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good, just a small correction and it's done.
source/fundamentals/linq.txt
Outdated
.. code-block:: csharp | ||
|
||
var query = queryableCollection | ||
.Select(r => Mql.Convert(r.RestaurantId, new ConvertOptions<int>( OnError = -1, OnNull = 0 ))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.Select(r => Mql.Convert(r.RestaurantId, new ConvertOptions<int>( OnError = -1, OnNull = 0 ))); | |
.Select(r => Mql.Convert(r.RestaurantId, new ConvertOptions<int> { OnError = -1, OnNull = 0 })); |
My bad, I used the wrong parenthesis in the example 🤦
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Pull Request Info
PR Reviewing Guidelines
JIRA - https://jira.mongodb.org/browse/DOCSP-49279
Staging Links
Self-Review Checklist