Sql – Programmatic control of the Delay Loaded property in LINQ to SQL

asp.netlazy-loadinglinq-to-sql

Using LINQ to SQL, is there any way to specify "Delay Loaded = true" for some properties on entities using code?

I can do it manually in the designer but I will lose that customization if the table is updated/rebound.

I know of DataLoadOptions and LoadWith(), but that's for using eager loading instead of lazy loading, and I want to specify lazy loading where eager loading is the default.

ScottGu made some interesting promises here but afaik he never followed up on it. 🙂

Best Answer

I found the following regaring lazy loading:

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

Here it is in full:

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

Don't know if this helps