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

Type-safe $set with positional operator "$"

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • 1.9.2
    • API
    • Fully Compatible

    Description

      Currently the only way to use a positional operator & for updating a field in embedded array is to use the not type safe Update.Set with manually constructing the statement like:

      Update.Set("MyArray.$.Value", newVal);

      A method can be added to the generic Update<TDocument> and UpdateBuilder<TDocument> to avoid hard-codding strings (there is already similar approach with Query<T>.ElemMatch):

      Update<MyDocument>.SetPositional(d => d.MyArray, a => a.Value, newVal);

      Attachments

        Activity

          People

            Unassigned Unassigned
            sunnybg Svetoslav Milenov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: