ServiceStack Ormlite UpdateNonDefaults for nullable type field

拟墨画扇 提交于 2019-12-25 04:16:07

问题


Please refer UpdateNonDefaults is ignoring boolean parameters set to false


回答1:


bool properties are now always included in UpdateNonDefaults() with this commit which will let you do the following:

public class Poco
{
    public int Id { get; set; }
    public bool Bool { get; set; }
}

var db = OpenDbConnection();
db.DropAndCreateTable<Poco>();

db.Insert(new Poco { Id = 1, Bool = true });
db.UpdateNonDefaults(new Poco { Bool = false }, x => x.Id == 1);
var row = db.SingleById<Poco>(1);
row.Bool // false

This change is available from v4.0.39+ that's now available on MyGet.



来源:https://stackoverflow.com/questions/29239823/servicestack-ormlite-updatenondefaults-for-nullable-type-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!