Question

I am making use of Subsonic SimpleRepository

i have a class:

public class X{public string abc {get; set;}private string def {get; set;}}

property "def" is only set within that class and i don't want the property to be visible externally, but for some reason when i save the object using Repo.Save(x) the private property is not persisted to the DB

Any help?

Was it helpful?

Solution

Set up a two data models, one that represents X in the front-end (public, visible) and one that represents X in the back-end (private, hidden):

namespace App.BackEnd // classes here are used for database storage
{
    public class X
    {
        public string abc { get; set; }
        public string def { get; set; }

        public FrontEnd.X ToFrontEnd()
        {
            return new FrontEnd.X
            {
                abc = abc
            };
        }
    }
}

namespace App.FrontEnd // classes here are used for public interfaces
{
    public class X
    {
        public string abc { get; set; }
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top