title: NHibernate querying on a string collection using Linq results in either error or empty collection
body: <p>I have a problem with selecting a string collection and have reproduced it with the following small example.</p>
  
  <p>Given the following SQL:</p>
  
  <pre><code>CREATE TABLE [Post] (
      [Id]    INT     IDENTITY NOT NULL,
      [Name]  NVARCHAR(20) NOT NULL,
      CONSTRAINT [PK_Post] PRIMARY KEY CLUSTERED ([Id])
  )
  CREATE TABLE [Category] (
      [Id]    INT     IDENTITY NOT NULL,
      [PostId]    INT NOT NULL,
      [Name]  NVARCHAR(20) NOT NULL,
      CONSTRAINT [FK_Category_Post] FOREIGN KEY ([PostId]) REFERENCES [Post]([Id])
  )
  INSERT INTO [Post] ([Name]) VALUES ('Post 1')
  INSERT INTO [Category] ([PostId], [Name]) VALUES (1, 'Alpha')
  </code></pre>
  
  <p>And the code (I used LINQPad):</p>
  
  <pre><code>void Main()
  {
      using (var sessionFactory = Fluently.Configure()
          .Database(MsSqlConfiguration.MsSql2008.Dialect&lt;MsSql2012Dialect&gt;().ConnectionString(@"Data Source=(localdb)\Projects;Initial Catalog=NhTest;"))
          .Mappings(x =&gt; {
              x.FluentMappings.Add(typeof(PostMap));
          })
          .BuildSessionFactory())
      using (var session = sessionFactory.OpenSession())
      {
          var post = session.Get&lt;Post&gt;(1);
          Debug.Assert(post.Categories.First() == "Alpha");
  
          try {
              var second = session.Query&lt;Post&gt;()
                  .Where(x =&gt; x.Id == 1)
                  .Select(x =&gt; new {
                      x.Categories,
                      x.Name,
                  })
                  .Single();
          }
          catch (Exception ex) {
              Debug.Fail(ex.ToString());
          }
  
          var third = session.Query&lt;Post&gt;()
              .Where(x =&gt; x.Id == 1)
              .Select(x =&gt; new {
                  x.Categories,
                  x.Name,
              })
              .ToList().First();
  
          Debug.Assert(third.Categories.Count() == 1, "Category count was " + third.Categories.Count());
      }
  }
  
  // Define other methods and classes here
  class Post
  {
      public virtual int Id { get; protected set; }
      public virtual string Name { get; protected set; }
      public virtual IList&lt;string&gt; Categories { get; protected set; }
  }
  
  class PostMap : ClassMap&lt;Post&gt;
  {
      public PostMap()
      {
          Id(x =&gt; x.Id);
          Map(x =&gt; x.Name);
  
          HasMany(x =&gt; x.Categories)
              .Table("Category")
              .Element("Name")
              .KeyColumn("PostId");
      }
  }
  </code></pre>
  
  <p>The first assert passes and this, in my mind, validates my mapping of the categories onto the post.</p>
  
  <p>The query in the try block throws an exception</p>
  
  <pre><code>'System.Linq.EnumerableQuery`1[System.Collections.Generic.IList`1[System.String]]' cannot be converted to type 'System.Linq.IQueryable`1[System.Object[]]
  </code></pre>
  
  <p>So I've changed it to the 3rd attempt you see in the code, calling <code>.ToList().First()</code>. This query does not throw any exception but the categories list is returned empty.</p>
  
  <p>Am I doing something wrong? Is there a better mapping technique to use here? Or are there workarounds to get my query working?</p>