Q:

Linq where clause tied to dropdownlist selectedvalue

I have a dropDownList1 with 3 values: N, U, All. I have dropDownList2 that is populated by a Linq statement with values filtered by the selection made in the first drop down during the SelectedIndexChanged event.
string theType = dropDownList1.SelectedValue;

var yearQuery = (from y in context
where y.Type == theType
orderby y.Year ascending
select y.Year).Distinct();

But, the option "All" in the first list is not one of the values in the Type column of the data set. I'd like it when someone selects "All" in the dropdown, it would return all of the records. Is there an equivalent of a * operator? Any ideas?

A:

Try this:
string theType = dropDownList1.SelectedValue;

var yearQuery = (from y in context                    
                orderby y.Year ascending
                select y.Year).Distinct();

if(theType != "All")
    yearQuery = yearQuery.Where(p=>p.Type == theType);

