如何使用MongoDB C#

时间:2019-01-29 22:48:32

标签: c# mongodb mongodb-query

我在Bson的 string 属性薪水以下,并且更新功能正常。

public class Children
{
    [BsonElement("salary")]
    public string salary{ get; set; }
}

public class EmpInfoData
{
    public Children Children  {get;set;}
}

//Update working fine with string salary data type.
UpdateDefinition<EmpInfoData> update = Builders<EmpInfoData>.Update.Set( x => x.children[-1].salary, "2340");

后来的薪水字段数据类型已更改为Integer。更改后,我得到错误。如何更新子类下的Integer字段?

public class Children
{
    [BsonElement("salary")]
    public int salary{ get; set; }
}
  

更新语句出错

     

无法将lambda表达式转换为类型'FiledDefinition-EmpInfoData,string-“,因为它不是委托类型

0 个答案:

没有答案