C# 无法将$push/$pushAll修饰符应用于非数组

C# 无法将$push/$pushAll修饰符应用于非数组,c#,mongodb,mongodb-.net-driver,C#,Mongodb,Mongodb .net Driver,我在SafeModeResult result=\u test.Update(查询,更新)中得到这个错误: 型号: public class Test { [BsonId] public string Id { get; set; } public string Name { get; set; } public string Address { get; set; } publ

我在
SafeModeResult result=\u test.Update(查询,更新)中得到这个错误

型号:

 public class Test
        {
          [BsonId]
          public string Id { get; set; }
          public string Name { get; set; }
          public string Address { get; set; }
          public IList<Comment> Comments { get; set; }
          public int TotalComments { get; set; }
          public DateTime LastModified { get; set; }
        }

        public class Comment
        {
          [BsonId]
          public string Id { get; set; }
          public string Detail { get; set; }
          public DateTime LastModified { get; set; }
        }
提琴手演奏:

http://localhost:49432/api/test/50f3f8365029d61bbc307f52

User-Agent: Fiddler
Content-Length: 37
Content-Type: application/json
Host: localhost:49432

{"Detail" : "This is great"}

我猜这是因为当我插入一个新文档时,我没有将注释设置为空数组

我也为此浪费了几个小时。感谢您的回复:)
IMongoQuery query = Query.EQ("_id", id);
comment.Id = ObjectId.GenerateNewId().ToString();
comment.LastModified = DateTime.UtcNow;
IMongoUpdate update = Update
    .PushWrapped("Comments", comment)
    .Inc("TotalComments", 1);
SafeModeResult result = _test.Update(query, update);

        return result.UpdatedExisting;
http://localhost:49432/api/test/50f3f8365029d61bbc307f52

User-Agent: Fiddler
Content-Length: 37
Content-Type: application/json
Host: localhost:49432

{"Detail" : "This is great"}