Kevin Buchan wrote:
Quote:
Let's say I have a class, Employee, with three properties: EmployeeID,
Name, Active. I want to find all active employees, and I want to
return a sequence of an anonymous type containing all of the Employee
fields plus one more.
>
In SQL, I might do this like so:
SELECT E.*, CURRENT_TIMESTAMP AS [Today] FROM Employee AS E
>
I know I can do something like this in Linq:
'Assume that I have a collection, Employees, holding the data I want
to filter on.
Dim myEmps = From E in Employees Where E.Active = True Select
E.EmployeID, E.Name, E.Active, [Today] = DateTime.Now()
>
What I'd REALLY like to do is not have to type out all of the property
names (e.g. "E.EmployeID, E.Name, E.Active") just to get them all. I'd
rather do something like the SQL example of "E.*".
>
Is this possible with Linq?
|
What you can do is e.g.
Dim myEmps = From E in Employees _
Where E.Active = True _
Select E, [Today] = DateTime.Now()
but then the items returned has two properties, one of type Employees,
one of type DateTime so you would need to access
For Each item in myEmps
Console.WriteLine(item.E.EmployeeID)
Next
I don't think there is a wildcard like E.* possible.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/