title: nHibernate Select statement for specific fields
body: <p>I'm using nHibernate with c# to get a list of records or strings from the database as show in the first couple of lines of code below.  This works fine.  What I want to do is select a few specific fields from the record and not the entire record.  I have tried various techniques and can't seem to find any examples on how to do this.  Could someone have a look at the code below and let me know if I am going off in the wrong direction.</p>
  
  <p>Thanks!</p>
  
  <pre><code>//  THIS WORKS - Retrieve a list of my records from the table.
  Ilist&lt;MyClass&gt; classList = db.Session.CreateQuery("FROM MyTable WHERE t.Name='AName'").List&lt;MyClass&gt;();
  
  
  //  THIS WORKS - Retrieve a list of strings from the table
  IList&lt;string&gt; stringList = db.Session.CreateQuery("SELECT c.ConstName FROM MyTable c WHERE c.Name='AName'").List&lt;string&gt;();
  
  
  //  THIS DOES NOT WORK (RUN-TIME ERRORS).  HOW CAN I SELECT ONLY A FEW FIELDS FROM EACH RECORD?
  //  This class contains only the records I want.
  public struct MyClassB
  {
      private string Name;
      private string Address;
  
      public string Name
      {
          get { return Name; }
          set { Name = value; }
      }
  
      public string Address
      {
          get { return Address; }
          set { stationName = Address; }
      }
  }      
  
  
  IList&lt;MyClassB&gt; classListB = db.Session.CreateQuery("SELECT t.Name, t.Address FROM MyTable t WHERE t.Name='AName'").List&lt;MyClassB&gt;();
  </code></pre>