Consider below
if(type== "S")
{
lstItem.ItemsSource = (from item in Items
where item.Property1 == "SomeValue"
select item);
}
else
{
lstItem.ItemsSource = (from item in Items
where item.Property2 == "SomeOtherValue"
select item);
}
How can you understand that the only difference between these two queries relates only to the name of the property (for the first it is Property1 , and for the second it is Property2 )
Is there a better way to refactor / write code in a structured mannner (some general method in which only the property name will be passed and the record will be filtered out accordingly), or is this the right way to do the same
Help is needed.
thank
user372724
source
share