Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Returning record versus fields only
Message
De
09/04/2012 10:18:42
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
LINQ
Titre:
Returning record versus fields only
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01540661
Message ID:
01540661
Vues:
88
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?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform