Consider the 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);
}
As can be figured out that the only difference between these two queries is only in the property name (for the first one it is Property1 & for the second it is Property2)
Is there any better way of refactoring / writing the code in a structured mannner(some common method where only the property name will be passed and the record will be filtered as per that) or this is the proper way of doing the same?
Need help.
Thanks