-
Notifications
You must be signed in to change notification settings - Fork 24
DOCSP-43911 - Implicit Client-Side Projection #242
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
Changes from 1 commit
617c38a
1b12da7
f8e0179
7c5003d
ab63a51
995ca45
5eb9f40
2b6bd0a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,8 +57,38 @@ The 3.0 driver release includes the following new features: | |
This type is available in .NET 5 and later. | ||
To learn more about the ``Half`` type, see the | ||
`Half Struct <https://learn.microsoft.com/en-us/dotnet/api/system.half?view=net-8.0>`__ | ||
API reference page on MSDN. | ||
|
||
API reference page on MSDN. | ||
|
||
- Adds support for implicit client-side projection when using the ``Find()`` and | ||
``Select()`` methods. In previous versions of the driver, you could perform client-side | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Beside the |
||
projection only after calling the ``ToEnumerable()`` or ``AsEnumerable()`` method, and | ||
only by using the ``Select()`` method, similar to the following examples: | ||
|
||
.. code-block:: csharp | ||
|
||
var find = collection | ||
.Find(doc => doc.Id == 1) | ||
.ToEnumerable() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not driver supported client-side projections. This is the user doing an EXPLICIT client-side projection by splitting their query into server-side and client-side parts and separating them by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My understanding was that this is currently the only way to do it, which is why I presented it as the "before" example. Is that wrong? Either way, I rearranged things to hopefully make it clearer. |
||
.Select(doc => new { R = MyFunction(doc.Name) }); | ||
|
||
var enumerable = collection.AsQueryable() | ||
.Where(doc => doc.Id == 1) | ||
.AsEnumerable() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also EXPLICIT like the |
||
.Select(doc => new { R = MyFunction(doc.Name) }); | ||
|
||
In {+driver-short+} v3.0, you can perform client-side projection directly in the | ||
``Find()`` and ``Select()`` methods, as shown in the following examples: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes but... they have to enable client-side projections to do this. |
||
|
||
.. code-block:: csharp | ||
|
||
var find = collection | ||
.Find(doc => doc.Id == 1) | ||
.Project(doc => new { R = MyFunction(doc.Name) }); | ||
|
||
var queryable = collection.AsQueryable() | ||
.Where(doc => doc.Id == 1) | ||
.Select(doc => new { R = MyFunction(doc.Name) }); | ||
|
||
.. _csharp-version-2.28: | ||
|
||
What's New in 2.28 | ||
|
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 won't be implicit.
Client-side projections are potentially undesirable and the current thinking is that they will have to "enable" client side projections in order to use them.
The current PR is not merged to master yet, but the two places client-side projections can be enabled are in the
MongoClientSettings
or in theFindOptions
orAggregateOptions
for an individual query.Theoretically they could be implicit, but that's not the current thinking.
Uh oh!
There was an error while loading. Please reload this page.
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.
Thanks for clarifying! I was trying to figure this out from the relevant ticket and PR but must have missed this aspect. I hope I got it right in these code samples, but please correct me if I'm wrong.