Categories

Tags


Lazy Object

I was inspired by the well known Lazy List implementation and decided to create a Lazy Object generic type.  There may be better ways to do this, but I thought that a Lazy Object would be a good way to handle the Many To One situations, just as the Lazy List handles the One To Many situations.  With out further ado, here is my Lazy Object code:

public class Lazy<T>
{
    private IQueryable<T> query;

    public Lazy(IQueryable<T> query)
    {
        this.query = query;
    }

    public T Get()
    {
        return query.SingleOrDefault();
    }
}

kick it on DotNetKicks.com

February 26, 2009 16:03 by jpsanders
E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed
Comments are closed