views:

137

answers:

0

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?