Florian Florian - 2 years ago 86
SQL Question

How to delay loading a property with linq to sql external mapping?

I have a table that contains some blob fields that I don't want to load by default.

In a dbml file it is possible to set the delay loaded property for such fields.

Is there a similar option for external mapping files?

Answer Source

I'm not familiar with "external mapping files", but this is basically how you do lazy loading with LINQ-to-SQL:

    private System.Data.Linq.Link<String> _content;
    [Column(Name = "content", DbType = "NVarChar(MAX) NOT NULL", Storage = "_content")]
    public String Content
        get { return this._content.Value; }
        set { this._content.Value = value; }

Using System.Data.Linq.Link<String> as the private variable causes that property to be delay loaded, unless delay loading is disabled on the DataContext.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download