开发者

Subsonic Simple Repository - Persist Private Property

开发者 https://www.devze.com 2023-01-04 15:30 出处:网络
I am making use of Subsonic开发者_运维技巧 SimpleRepository i have a class: public class X{public string abc {get; set;}private string def {get; set;}}

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; }
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消