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();
}
}
