title: What is the quickest way to query a database with LINQ?
body: <p>I'm reading a WROX book on LINQ and the author is performing LINQ on a database. Essentially he is accessing the database as an object as shown in the code below.</p>
  
  <p>But I don't see how he expects to "access the database as an object", even the downloaded code gets an error on "db.DirectoryInformation" saying "DirectoryInformation" is unknown. </p>
  
  <p>What am I missing? I would think I first need to create LINQ-to-SQL classes or an ADO.NET EDM or is there even a more direct way to hook LINQ up to a database, i.e. just by creating a database class and that inherits from DataContext?</p>
  
  <pre><code>AdventureWorks db = new AdventureWorks("Integrated Security=sspi");
  
  ...
  
      [Database(Name = "AdventureWorks")]
      public class AdventureWorks : DataContext
      {
          //public Table&lt;DirInfo&gt; DirectoryInformation;
          public AdventureWorks(string connection) : base(connection) { }
          public Table&lt;DirectoryInformation&gt; DirectoryInformation;
      }
  </code></pre>
  
  <p><strong>You can <a href="http://www.wrox.com/WileyCDA/WroxTitle/Professional-LINQ.productCd-0470041811,descCd-DOWNLOAD.html" rel="nofollow noreferrer">download the whole code here</a>, chapter 1, LINQ.sln.</strong></p>