Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>LINQ to SQL supports <a href="http://en.wikipedia.org/wiki/Lazy_loading" rel="nofollow noreferrer">lazy loading</a> individual properties. In the DBML designer, you can set <code>Delay Loaded</code> to <code>true</code> in a column's properties. Columns that are delay loaded will not be included in the initial <code>SELECT</code>. If you try to access the object's property and it has not been loaded yet, then another <code>SELECT</code> statement will be executed to bring this value from the DB.</p> <p>If you are editing the DBML file by hand, set <code>&lt;Column IsDelayLoaded="true"&gt;</code>. If you are writing your LINQ to SQL classes by hand, it is as simple as declaring the property's backing field as a <code>Link&lt;T&gt;</code> instead of <code>T</code>. For example:</p> <pre><code>[Table] public class Person { private Link&lt;string&gt; _name; [Column(Storage = "_name")] public string Name { get { return _name.Value; } set { _name.Value = value; } } } </code></pre> <p>See also the "Delay/Lazy Loading" section in <a href="http://weblogs.asp.net/scottgu/archive/2007/05/29/linq-to-sql-part-2-defining-our-data-model-classes.aspx" rel="nofollow noreferrer">this post by Scott Guthrie</a>.</p> <hr> <p>Update: The above answer applies if you want the column to still be available when you need it. It will not be included in <code>SELECT</code>s unless you specifically ask for it (see <code>LoadOptions</code>) or try to access it.</p> <p>If you just don't want to use or access the column at all, and you don't want it available as a class property, then go with <a href="https://stackoverflow.com/questions/852679/linq-to-sql-dont-fetch-a-particular-column/852934#852934">Serapth's answer</a> of removing the column from the DBML file. Be sure you understand the implications, such as the loss of concurrency checking on that column.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload