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:
Unable to find source-code formatter for language: csharp. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
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):
Unable to find source-code formatter for language: csharp. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
Update<MyDocument>.SetPositional(d => d.MyArray, a => a.Value, newVal);
- duplicates
-
CSHARP-531 Support the $ positional operator when building a query for updating a collection
- Closed