开发者

Customized mapping in poco of Entity framework

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜