Web Log di Adrian Florea

"You know you've achieved perfection in design, not when you have nothing more to add, but when you have nothing more to take away." Antoine de Saint-Exupery
posts - 440, comments - 2715, trackbacks - 3944

My Links

Archives

Post Categories

Image Galleries

.RO Blogs

.RO People

.RO Sites

Blogs

Furls

Links

vinCitori

Lazy loading in una riga

Carino questo modo proposto da Frank Quednau di implementare il lazy loading utilizzando l'operatore di null coalescing (ECMA-334, 14.12) e il fatto che il risultato di un'assegnazione e' il valore assegnato all'operando sinistro (ECMA-334, 14.14.1):

internal sealed class PersonProxy : Person
{
    public override AddressCollection Addresses
    {
        get
        {
            return base.Addresses ?? (base.Addresses = new PersonDataMapper().GetAddressesByCode(this.Code));
        }
        set
        {
            base.Addresses = value;
        }
    }
}

A me sembra molto espressivo.

Print | posted on giovedì 29 maggio 2008 01:04 | Filed Under [ Pattern Dappertutto ]

Powered by:
Powered By Subtext Powered By ASP.NET