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

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

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.0
    • Affects Version/s: 1.5
    • Component/s: Feature Request
    • Labels:

      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

            Assignee:
            Unassigned Unassigned
            Reporter:
            sebm Seb Michaud
            Votes:
            18 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved: