Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
More complicated with Linq
Message
From
11/04/2012 10:12:34
 
 
General information
Forum:
ASP.NET
Category:
LINQ
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01540963
Message ID:
01541050
Views:
22
>No. You can new up an existing type or an anonymous type - no other options. Well you could go down the DLR route (but I don't like it):
var anon = clients.Select(x => new { Surname = x.LastName, GivenName = x.FirstName }).FirstOrDefault();
>DoSomething(anon);
Then:
   void DoSomething (dynamic d)
>    {
>        string Surname = d.Surname;
>    }
(Sorry C# version but conversion should be simple)

Maybe I am not understanding it, but what I see here is some code to, in fact, add the property in the returned object instead of the sub object itself. But, in order to accomplish this, this code seems to execute a method after the initial query and adjust to include an additional property. But, the initial query would still return all the fields, correct? If that is the case, as some of it is an object, isn't that object be returned as well in that query? Or, is it that it will only become available from a secondary call made to the object result, which will go again across the wire to get the sub object?
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform