Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Returning record versus fields only
Message
From
09/04/2012 10:18:42
 
 
To
All
General information
Forum:
ASP.NET
Category:
LINQ
Title:
Returning record versus fields only
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01540661
Message ID:
01540661
Views:
87
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
Next
Reply
Map
View

Click here to load this message in the networking platform