I want to run a query to get a string array of distinct "logName" items for a logType. The following works great:
Dim stringArray() As String = (From item In dc.Vw_Logs
Where item.LogType = [Passed in logType]
Select item.LogName Distinct).ToArray()
However, this only works when a specific LogType is set. I would like the logType clause to be optional. To try and achieve this I have rewritten the query:
Dim q = From item In dc.Vw_Logs Distinct
If not logType is nothing Then
q = q.Where(Function(item) item.LogType = logType)
End If
q.Select(Function(item) item.LogName)
Dim stringArray() As String = q.ToArray()
With this I get the following error:
Value of type '1-dimensional array of Vw_Log' cannot be converted
to '1-dimensional array of String'
What is the best way to get round this? I would like to avoid iterating each item and casting.
Thanks for any help