This is fairly complex query for criteria api.

Tuna Toksöz
Eternal sunshine of the open source mind.

http://devlicio.us/blogs/tuna_toksoz
http://tunatoksoz.com
http://twitter.com/tehlike




On Thu, Aug 20, 2009 at 4:42 PM, Craig van Nieuwkerk <crai...@gmail.com>wrote:

>
> 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.
>
> Any help appreciated.
>
>            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);
>
> Craig
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to nhusers@googlegroups.com
To unsubscribe from this group, send email to 
nhusers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to