I have two classes:
public class Client
{
[BsonId]
public string Id { get; set; }
public ICollection<OtherData> Other { get; set; }
}
and
public class OtherData
{
[BsonId]
public string Id { get; set; }
public string Text { get; set; }
}
I have a collection of documents of Client.
I'd like to update a item on Other
based on it's id.
So I have this code.
Expression<Func<Client, bool>> filter = x =>
x.Id == id
&& x.Other.Any(t => t.Id == idOther);
var update = new UpdateDefinitionBuilder<Client>()
.Set(x => x.Other.ElementAt(-1), dadoBancario);
await _collection.FindOneAndUpdateAsync(filter, update);
But when I run this code, I get this error:
Command findAndModify failed: The dollar ($) prefixed field 'Other.$' in 'Other.$' is not valid for storage.. MongoDB.Driver.MongoCommandException at MongoDB.Driver.Core.WireProtocol.CommandWireProtocol
1.ProcessReply(ConnectionId connectionId, ReplyMessage
1 reply)
I'm using Cosmos DB. Is this some compatibillity issue?
Or there is another way that I can go?