Search code examples
c#.netservicestackormlite-servicestack

UpdateNonDefaults is not working with ServiceStack for Boolean Value


I am using ServiceStack ORMLite with Sql Server. Now in my Servicestack , POCO class i have a boolean field which is represented by bit not null in Sql Server . Now i want this boolean value to be updated lets say from true to false and vice-versa.But this is not happening , apart from that boolean column all other columns are getting updated correctly.I am using following line to perform update operation..

db.UpdateNonDefaults(ChangeBool, p => p.id== request.StudentId);

Please help me to resolve this issue.Thanks..


Solution

  • You can't use NonDefaults API to do this since false is the default value for a boolean and UpdateNonDefaults() only updates non default values.

    You can instead use UpdateOnly and specify that you want to update the bool column, e.g:

    db.UpdateOnly(new ChangeBool { Bool = false }, 
        onlyFields: x => x.Bool, 
        where: x => x.Id == request.StudentId);