开发者

Customized mapping in poco of Entity framework

开发者 https://www.devze.com 2022-12-19 06:05 出处:网络
Sometimes i would like to serial开发者_开发问答ize dynamic properties to one field in database and lazy deserialize field to dynamic properteis in object view, see following in object view:

Sometimes i would like to serial开发者_开发问答ize 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?

0

精彩评论

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