views:

389

answers:

1

I am using the version 1.0 release of Linq for nHibernate. When I run the following linq statements I receive the error

not a single-length projection: Surname

I can find very few references to this on the web and looking into the source it says it should never occur! ClientID is a Int type and Surname is a string. When I comment out all the string fields in the projection and just leave ClientID it runs ok, but as soon as I add surname back it errors.

var context = m_ClientRepository.Linq;

var result = (from client in context
              from address in client.Addresses
              from contact in client.Contacts
              where client.Surname.StartsWith(surname)
              && client.GivenName.StartsWith(givenName)
              && contact.Value.StartsWith(phoneNumber)
              group client by new { client.ClientID, client.Surname, client.GivenName } into clientGroup
              select new ClientSearchDTO()
              {
                  ClientID = clientGroup.Key.ClientID,
                  Surname = clientGroup.Key.Surname,
                  GivenName = clientGroup.Key.GivenName,
                  Address = clientGroup.Max(x => x.Addresses.FirstOrDefault().Address),
                  PhoneNumber = clientGroup.Max(x => x.Contacts.FirstOrDefault().Value)
              })
              .Skip(Paging.FirstRecord(pageNumber))
              .Take(5);
+3  A: 

AFAIK, subqueries in select clauses aren't supported in LINQ to nHibernate 1.0.

This may be source of your problem.

elder_george