문제

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?

도움이 되었습니까?

해결책

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; }
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top