>I need to understand something in regards to the way LINQ work went returning records versus only a few fields.
>
>I have a declaration like this:
>
>
> Public oClient As ClientAPI.ClientService.Client = Nothing
>
>
>Then, I can do my SQL:
>
>
> oClient = (From c
> In oGeneric.GetClients()
> Where c.Id = nClientID).FirstOrDefault()
>
>
>However, if I have to return only a few fields, I will adjust for something like this:
>
>
> oClient = (From c
> In oGeneric.GetClients()
> Where c.Id = nClientID
> Select c.FirstName,cLastName).FirstOrDefault()
>
>
>This will then generate this design time error:
>
>"Value of type 'anonymous type (line 87)' cannot be converted to 'ClientAPI.ClientService.Client'."
>
>Obviously , the declaration is done in a way that it expects the record to be returned. So, when I try to select only a few fields, it does not like it.
>
>Can someone share some light on that?
The exeption says it all. You are requiring a return type of ClientAPI.ClientService.Client but the select is generating an anonymous type.