Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-531

Support the $ positional operator when building a query for updating a collection

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 1.5
    • Fix Version/s: 2.0
    • Component/s: Feature Request
    • Labels:

      Description

      The feature to add strongly typed LINQ support to the builders doesn't suppport updating of nested collections.

      For example, it's possible to write an update like:

      statusCollection.Update(
      Query<StatusGroup>.Where(sg => sg.Statuses.Any(s => s.Id == status.Id)),
      Update.Set("Statuses.$.UpdateTime", DateTime.Now)
      .Set("Statuses.$.Name", "name")
      );

      It would be nice if it was possible to write something like:

      statusCollection.Update(
      Query<StatusGroup>.Where(sg => sg.Statuses.Any(s => s.Id == status.Id)),
      Update<StatusGroup, Status>.Set(sg => sg.Statuses, s => s.UpdateTime, DateTime.Now)
      .Set(sg => sg.Statuses, s => s.Name, "name")
      );

      Eventually it would be nice to support multi-level nested collections but that might be dependant on https://jira.mongodb.org/browse/SERVER-831

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                18 Vote for this issue
                Watchers:
                11 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: