Given the following two cases, which one is preferable (If they're both bad, doing it a completely different way is an option too)?
Convert.ToInt32
called in Where
:
var items = GetItems();
if (aDropDownList.SelectedIndex > 0)
{
items = items.Where(x =>
x.IntProperty == Convert.ToInt32(aDropDownList.SelectedValue));
}
Convert.ToInt32
called before Where
:
var items = GetItems();
if (aDropDownList.SelectedIndex > 0)
{
int selectedDropDownValue = Convert.ToInt32(aDropDownList.SelectedValue);
items = items.Where(x => x.IntProperty == selectedDropDownValue);
}