Search code examples
ormlite-servicestack

ServiceStack Ormlite UpdateNonDefaults for nullable type field


Please refer UpdateNonDefaults is ignoring boolean parameters set to false


Solution

  • 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.