The error is because q is not strings but the type contained in dc. Vw_Logs I don't do much programming in VB anymore but this should get you close Dim q = From item In dc Where (logType Is Nothing Or item. LogType = logType) Select item.
LogName Distinct logType Is Nothing Or item. LogType = logType If logType has a value, you will get the items that match; otherwise, you will get all of the items.
The error is because q is not strings but the type contained in dc. Vw_Logs. I don't do much programming in VB anymore but this should get you close.
Dim q = From item In dc Where (logType Is Nothing Or item. LogType = logType) Select item. LogName Distinct logType Is Nothing Or item.
LogType = logType If logType has a value, you will get the items that match; otherwise, you will get all of the items.
This won't work because if the logType (passed into the select method) is nothing, then this will result in no matches (I want all matches in this case) – James May 12 '09 at 20:44 1 Jeremy just misread your logic, but he's fundamentally correct. The Where clause should just be (logType Is Nothing Or item. LogType = logType) – Collin K May 12 '09 at 21:30 Thanks for the catch.
– Jeremy May 12 '09 at 21:42 I think we have our wires crossed. The logType in the database will ALWAYS have a value. However, the method that I am trying to make takes a string of "logType".
If this is null, I would like the linq query to simply not include a filter for the logType (thus getting across all log types). If I use the suggested logic above, this will always return no results when the logType passed in to the method is null. – James May 12 '09 at 22:20 I just checked and it works!
I did not know you could mix checks against both server variables and database values in a single linq where statement. Wow! That is great.
Thanks for your assistance. – James May 12 '097 at 14:00.
The problem is that this line q. Select(Function(item) item. LogName) doesn't change q, it simply discards the result of the select so that when you do Dim stringArray() As String = q.ToArray() You're trying to convert the original q (which is of type Vw_Log) to an array of strings.
Replace the last two lines with this: Dim stringArray() As String = q. Select(Function(item) item. LogName).ToArray().
Do not reuse q. The first assignment is Vw_Log(), the second is String(). You can also combine the last two lines to avoid this.
Sorry - I can't seem to get the above comment to format any better! – James May 12 '09 at 20:51 This seems to result in an inner SQL select statement: Dim qTyped = From item In dc. Vw_Log Distinct If logType Nothing Then qTyped = qTyped.
Where(Function(item) item. LogType = logType) Dim q = qTyped. Select(Function(item) item.
LogName).Distinct() – James May 12 '09 at 20:55.
I would like to avoid iterating each item and casting.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.