R
Ronald S. Cook
The below code works, but returns a list like:
(Please Select),
Adams, Jon
Baker, Sue
Davis, Don
.... i.e. there's a comma appended to (Please Select) that I'd really like to
get rid of.
Here's the code:
***************************************************
'1) Build database query.
Dim _Query As IEnumerable(Of Employee) = _
From e In dc.Employees _
Where e.Lookup.LookupCode <> "INA" _
Order By e.EmployeeLastName, _
e.EmployeeFirstName
'2) Execute query and store results in list.
Dim _List As IList(Of Employee) = _Query.ToList()
'3) Insert extra entry in list.
Dim _Employee As New Employee()
_Employee.EmployeeLastName = "(Please Select)"
_Employee.EmployeeFirstName = ""
_List.Insert(0, _Employee)
'4) Project list with concatenated field.
Dim _QueryWithSelect As IEnumerable = _
(From xyz In _List _
Select xyz.EmployeeId, _
EmployeeName = xyz.EmployeeLastName & ", " & _
xyz.EmployeeFirstName).ToList()
'5) Return.
Return _QueryWithSelect
***************************************************
I think I need to insert the (Please Select) record after the object with
the concatenated "EmployeeName" has been created, but I'm not sure how.
Thanks for any help,
Ron
(Please Select),
Adams, Jon
Baker, Sue
Davis, Don
.... i.e. there's a comma appended to (Please Select) that I'd really like to
get rid of.
Here's the code:
***************************************************
'1) Build database query.
Dim _Query As IEnumerable(Of Employee) = _
From e In dc.Employees _
Where e.Lookup.LookupCode <> "INA" _
Order By e.EmployeeLastName, _
e.EmployeeFirstName
'2) Execute query and store results in list.
Dim _List As IList(Of Employee) = _Query.ToList()
'3) Insert extra entry in list.
Dim _Employee As New Employee()
_Employee.EmployeeLastName = "(Please Select)"
_Employee.EmployeeFirstName = ""
_List.Insert(0, _Employee)
'4) Project list with concatenated field.
Dim _QueryWithSelect As IEnumerable = _
(From xyz In _List _
Select xyz.EmployeeId, _
EmployeeName = xyz.EmployeeLastName & ", " & _
xyz.EmployeeFirstName).ToList()
'5) Return.
Return _QueryWithSelect
***************************************************
I think I need to insert the (Please Select) record after the object with
the concatenated "EmployeeName" has been created, but I'm not sure how.
Thanks for any help,
Ron