Persistance ignorance and lazy loading
<p>Hey I cannot find solution to such a problem:
I'm implementing generic interface for EAV pattern </p>

<p>Want to execute such a code: </p>

<pre><code>    Entity&lt;GPS&gt; gps = new Entity&lt;GPS&gt;("Path.To.GPS");
    Console.WriteLine(gps.Attributes.Latitude);
    Console.WriteLine(gps.Attributes.Longitude);
</code></pre>

<p>Where: </p>

<pre><code>    public class GPS : IAttributes
    {
        public double Latitude { get; set; }
        public double Longitude { get; set; }
    }

    public abstract class Entity
    {
        public IAttributes Attributes { get; set; }
        public string Path { get; set; }

        public Entity(string path)
        {
            this.Path = path;
        }
    }

    public class Entity&lt;T&gt; : Entity
        where T : IAttributes, new()
    {
        private T attributes = new T();

        new public T Attributes
        {

            get { return attributes; }

            set { attributes = value; }

        }
        public Entity(string path)
            : base(path)
        { }
    }

    public interface IAttributes
    { 
        /* Empty by design */
    }
</code></pre>

<p>Its easy to add to Entity class method for data loading
iterate through all parameters in T and load them from some source</p>

<p>Easy path:</p>

<pre><code>    Entity&lt;GPS&gt; gps = new Entity&lt;GPS&gt;("Path.To.GPS");
    gps.Reload(); // &lt;-- ADD THIS HERE
    Console.WriteLine(gps.Attributes.Latitude);
    Console.WriteLine(gps.Attributes.Longitude);
</code></pre>

<p>but how to do lazy loading ?</p>

<p><br><br>
is it possible to "attach" some code to accessor of every property in GPS class without modifying it, don't want to add and base classes or interfaces to it </p>

<p>Thanks for any advices.</p>
