如何更新图片的更新列表?
模型:
public class Test
{
[BsonId]
public string Id { get; set; }
public string Name { get; set; }
public List<Picture> Pic {get; set; }
public DateTime LastModified { get; set; }
}
public class Picture
{
public string Name{ get; set;}
public int Size {get; set;}
}
更新代码:
IMongoUpdate update = Update
.Set("Name", test.Name)
.Set("Address", test.Address)
.Set("LastModified", test.LastModified);
结果:
{
"_id": "50d3dbce1292dd2e98af1dd1",
"Name": "Bubba",
"Address": "1111",
"Pic" : [{"Name": "test1.jpg", "Size":"1000"}, {"Name": "test2.jpg", "Size":"2000"}],
"LastModified": {
"$date": "2012-12-21T03:47:26.535Z"
}
}