From 617c38a57fb1aa68efade377d6571d0d5c2bec1f Mon Sep 17 00:00:00 2001 From: Mike Woofter <108414937+mongoKart@users.noreply.github.com> Date: Thu, 26 Sep 2024 17:02:52 -0500 Subject: [PATCH 1/6] first draft --- source/whats-new.txt | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/source/whats-new.txt b/source/whats-new.txt index 9ac12d90..1b788943 100644 --- a/source/whats-new.txt +++ b/source/whats-new.txt @@ -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 `__ - 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 + 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() + .Select(doc => new { R = MyFunction(doc.Name) }); + + var enumerable = collection.AsQueryable() + .Where(doc => doc.Id == 1) + .AsEnumerable() + .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: + + .. 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 From f8e0179b0ace9455211e909e2ae98fd0a6fcc7d2 Mon Sep 17 00:00:00 2001 From: Mike Woofter <108414937+mongoKart@users.noreply.github.com> Date: Wed, 2 Oct 2024 16:03:54 -0500 Subject: [PATCH 2/6] feedback --- source/whats-new.txt | 90 ++++++++++++++++++++++++++++++++------------ 1 file changed, 65 insertions(+), 25 deletions(-) diff --git a/source/whats-new.txt b/source/whats-new.txt index b53e09f8..1c28bd42 100644 --- a/source/whats-new.txt +++ b/source/whats-new.txt @@ -71,36 +71,76 @@ The 3.0 driver release includes the following new features: `TimeOnly Struct. `__ 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 +- Adds support for client-side projection when using the ``Find()`` method, + the ``Select()`` method, or the ``Project()`` aggregation stage. + In previous versions of the driver, you could perform client-side 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() - .Select(doc => new { R = MyFunction(doc.Name) }); + only within the ``Select()`` method. - var enumerable = collection.AsQueryable() - .Where(doc => doc.Id == 1) - .AsEnumerable() - .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: + Select a tab below to see how to enable and use client-side projection for the + corresponding method. + + .. tabs:: + + .. tab:: Find() Method + :tabid: find-method + + .. code-block:: csharp + + // Enable client-side projection + var findOptions = new FindOptions; + findOptions.TranslationOptions = new ExpressionTranslationOptions + { + EnableClientSideProjections = true + }; + + var find = collection + .Find(doc => doc.Id == 1, findOptions); + .Project(doc => new { R = MyFunction(doc.Name) }); + + .. tab:: Select() Method + :tabid: select-method + + .. code-block:: csharp + + // Enable client-side projection + var translationOptions = new ExpressionTranslationOptions + { + EnableClientSideProjections = true + }; + + var queryable = collection + .AsQueryable(translateOptions) + .Where(doc => doc.Id == 1) + .Select(doc => new { R = MyFunction(doc.Name) }); + + .. tab:: Project() Method + :tabid: project-method + + .. code-block:: csharp + + // Enable client-side projection + var aggregateOptions = new AggregateOptions; + aggregateOptions.TranslationOptions = new ExpressionTranslationOptions + { + EnableClientSideProjections = true + }; + + var aggregate = collection + .Aggregate(pipeline, aggregateOptions) + .Project(doc => new { R = MyFunction(doc.Name) }); + + .. tip:: MongoClientSettings - .. code-block:: csharp + To enable client-side projection for all queries on a client, set the + ``TranslationOptions`` property of the ``MongoClientSettings`` object to ``true``. + + To learn more about using the aggregation pipeline with the {+driver-short+}, see + :ref:`csharp-aggregation`. - var find = collection - .Find(doc => doc.Id == 1) - .Project(doc => new { R = MyFunction(doc.Name) }); +For more information about this release, see the :github:`v3.0 release notes +`. - 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 From ab63a511db7beadc690d7bf04adf3aab56da93f7 Mon Sep 17 00:00:00 2001 From: Mike Woofter <108414937+mongoKart@users.noreply.github.com> Date: Wed, 2 Oct 2024 16:05:47 -0500 Subject: [PATCH 3/6] fix --- source/whats-new.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/whats-new.txt b/source/whats-new.txt index 0c204515..402b26f9 100644 --- a/source/whats-new.txt +++ b/source/whats-new.txt @@ -121,7 +121,7 @@ The 3.0 driver release includes the following new features: }; var queryable = collection - .AsQueryable(translateOptions) + .AsQueryable(translationOptions) .Where(doc => doc.Id == 1) .Select(doc => new { R = MyFunction(doc.Name) }); From 995ca4550bb06dc370df8486fed5cfe4eedeb5e2 Mon Sep 17 00:00:00 2001 From: Mike Woofter <108414937+mongoKart@users.noreply.github.com> Date: Wed, 2 Oct 2024 16:11:56 -0500 Subject: [PATCH 4/6] clarify --- source/whats-new.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/whats-new.txt b/source/whats-new.txt index 402b26f9..54838097 100644 --- a/source/whats-new.txt +++ b/source/whats-new.txt @@ -88,8 +88,8 @@ The 3.0 driver release includes the following new features: projection only after calling the ``ToEnumerable()`` or ``AsEnumerable()`` method, and only within the ``Select()`` method. - Select a tab below to see how to enable and use client-side projection for the - corresponding method. + To learn how to enable and use client-side projection for a driver method, select the + corresponding tab: .. tabs:: From 5eb9f4054ce6aeeb1201cbeafaa0d6e46def43a2 Mon Sep 17 00:00:00 2001 From: Mike Woofter <108414937+mongoKart@users.noreply.github.com> Date: Thu, 3 Oct 2024 11:39:25 -0500 Subject: [PATCH 5/6] feedback --- source/whats-new.txt | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/source/whats-new.txt b/source/whats-new.txt index 54838097..b465ca43 100644 --- a/source/whats-new.txt +++ b/source/whats-new.txt @@ -82,11 +82,11 @@ The 3.0 driver release includes the following new features: `TimeOnly Struct. `__ API reference page on MSDN. -- Adds support for client-side projection when using the ``Find()`` method, - the ``Select()`` method, or the ``Project()`` aggregation stage. +- Adds support for implicit client-side projection when using the ``Find()`` method, + the ``Select()`` method, or the ``Project()`` aggregation stage with the LINQ3 provider. In previous versions of the driver, you could perform client-side - projection only after calling the ``ToEnumerable()`` or ``AsEnumerable()`` method, and - only within the ``Select()`` method. + projection with the LINQ3 provider only after calling the ``ToEnumerable()`` or + ``AsEnumerable()`` method, and only within the ``Select()`` method. To learn how to enable and use client-side projection for a driver method, select the corresponding tab: @@ -99,7 +99,7 @@ The 3.0 driver release includes the following new features: .. code-block:: csharp // Enable client-side projection - var findOptions = new FindOptions; + var findOptions = new FindOptions(); findOptions.TranslationOptions = new ExpressionTranslationOptions { EnableClientSideProjections = true @@ -115,13 +115,14 @@ The 3.0 driver release includes the following new features: .. code-block:: csharp // Enable client-side projection - var translationOptions = new ExpressionTranslationOptions + var aggregateOptions = new AggregateOptions(); + aggregateOptions.TranslationOptions = new ExpressionTranslationOptions { EnableClientSideProjections = true }; var queryable = collection - .AsQueryable(translationOptions) + .AsQueryable(aggregateOptions) .Where(doc => doc.Id == 1) .Select(doc => new { R = MyFunction(doc.Name) }); @@ -131,14 +132,14 @@ The 3.0 driver release includes the following new features: .. code-block:: csharp // Enable client-side projection - var aggregateOptions = new AggregateOptions; + var aggregateOptions = new AggregateOptions(); aggregateOptions.TranslationOptions = new ExpressionTranslationOptions { EnableClientSideProjections = true }; var aggregate = collection - .Aggregate(pipeline, aggregateOptions) + .Aggregate(aggregateOptions) .Project(doc => new { R = MyFunction(doc.Name) }); .. tip:: MongoClientSettings From 2b6bd0aab6d4d305a3903dd52355a99f01d9ead8 Mon Sep 17 00:00:00 2001 From: Mike Woofter <108414937+mongoKart@users.noreply.github.com> Date: Thu, 3 Oct 2024 13:35:23 -0500 Subject: [PATCH 6/6] remove select method --- source/whats-new.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/whats-new.txt b/source/whats-new.txt index b465ca43..d4afdbe7 100644 --- a/source/whats-new.txt +++ b/source/whats-new.txt @@ -86,7 +86,7 @@ The 3.0 driver release includes the following new features: the ``Select()`` method, or the ``Project()`` aggregation stage with the LINQ3 provider. In previous versions of the driver, you could perform client-side projection with the LINQ3 provider only after calling the ``ToEnumerable()`` or - ``AsEnumerable()`` method, and only within the ``Select()`` method. + ``AsEnumerable()`` method. To learn how to enable and use client-side projection for a driver method, select the corresponding tab: