Can ServiceStack OrmLite set a a property with a non-public setter?

195 views Asked by At

Is there any way to make ServiceStack OrmLite set a property when its setter is not public? This would be very useful for keeping the class safer to use in some cases, e.g. when there are 2 dependent properties and I want the user to call a method to set them both at once. OrmLite still needs to be able to set them when reading from the database, though, so it would be great if they could be private. An artificial example:

    public class MyObject
    {
        public string One { get; private set; }
        public string Two { get; private set; }

        public void SetOneOrTwo(bool one, string value)
        {
            if (one)
            {
                One = value;
                Two = null;
            }
            else
            {
                One = null;
                Two = value;
            }
        }
    }
1

There are 1 answers

3
mythz On

No, OrmLite (like most of ServiceStack) works with code-first POCOs and respects your models public API by only populating public writable properties.