-
Notifications
You must be signed in to change notification settings - Fork 24
DOCSP-45003: Specify Fields to Include #291
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
Conversation
✅ Deploy Preview for mongodb-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 with a few small comments!
|
||
The following example uses the ``Find()`` method to find all restaurants in which the ``name`` | ||
field value is ``"Emerald Pub"``. Then, the code calls the ``Project()`` | ||
method to instruct the find operation to include the ``name`` and ``address`` fields |
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.
[q] Should this be updated to match the code snippet?
method to instruct the find operation to include the ``name`` and ``address`` fields | |
method to instruct the find operation to include the ``name`` and ``cuisine`` fields |
Specify Fields to Exclude | ||
~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
To specify the fields to include from the result, chain the ``Project()`` method |
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.
Typo:
To specify the fields to include from the result, chain the ``Project()`` method | |
To specify the fields to exclude from the result, chain the ``Project()`` method |
[BsonElement("coord")] | ||
public double[] Coordinates { get; set; } | ||
|
||
public string Street { get; set; } |
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.
Did you mean to omit [BsonElement]
here?
|
||
public class Address | ||
{ | ||
public string Building { get; set; } |
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.
Did you mean to omit [BsonElement] here?
|
||
In this guide, you can learn how to specify which fields to return from a read | ||
operation by using a **projection**. A projection is a document that specifies | ||
which fields MongoDB returns from a query. |
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.
Something to consider is that projections don't play nicely with POCOs.
When you only return some of the fields from the server your POCO is incomplete. Depending on how the serialization is done either the missing fields will be null
(or other suitable default value) in your POCO result or perhaps even an exception might be thrown for missing fields.
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'll update this page to avoid using POCOs
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
(cherry picked from commit 79d61d8)
(cherry picked from commit 79d61d8)
(cherry picked from commit 79d61d8)
(cherry picked from commit 79d61d8)
(cherry picked from commit 79d61d8)
(cherry picked from commit 79d61d8)
(cherry picked from commit 79d61d8)
(cherry picked from commit 79d61d8)
(cherry picked from commit 79d61d8)
(cherry picked from commit 79d61d8)
Pull Request Info
PR Reviewing Guidelines
JIRA - https://jira.mongodb.org/browse/DOCSP-45003
Staging Links
Self-Review Checklist