Customized mapping in poco of Entity framework

最后都变了- 提交于 2019-12-24 03:28:05

问题


Sometimes i would like to serialize dynamic properties to one field in database and lazy deserialize field to dynamic properteis in object view, see following in object view:

public IDictionary<string, string> _properties;
public IDictionary<string, string> Properties
{
    get
    {
        if (_properties == null)
        {
            _properties = new Dictionary<string, string>();
            Deserialize(_properties, PropertyString);
        }
        return _properties;
    }
}

I know how to do it in ef 3.5. I add entity self intercept function when persistence by override SaveChanges of context and have to write some invasive code in entity. But how to do it in poco of ef 4.0? any better idea for clean code in poco?

来源:https://stackoverflow.com/questions/2219609/customized-mapping-in-poco-of-entity-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!