<div>
Hello,
I have a problem with filter my list with operator AND and OR.
//In searchField1 DropDownList
Index1 = Title
Index2 = Author1
Index3 = Publisher
//In searchField2 DropDownList
Index1 = Title
Index2 = Author1
Index3 = Publisher
I can get searchField1 Dropdownlist filter with the following:
lstFirst = searchField1_Index == 1 ? (lstFirst.Where(fst => fst.Title.Contains(searchKey1))).ToList<oData.vwBook>() :
searchField1_Index == 2 ? (lstFirst.Where(fst => fst.Author1.Contains(searchKey1))).ToList<oData.vwBook>() :
searchField1_Index == 3 ? (lstFirst.Where(fst => fst.Publisher.Contains(searchKey1))).ToList<oData.vwBook>() :
lstFirst.ToList<oData.vwBook>();
and searchField2 Dropdownlist filter with the following:
lstSecond = searchField2_Index == 1 ? (lstSecond.Where(fst => fst.Title.Contains(searchKey1))).ToList<oData.vwBook>() :
searchField2_Index == 2 ? (lstSecond.Where(fst => fst.Author1.Contains(searchKey1))).ToList<oData.vwBook>() :
searchField2_Index == 3 ? (lstSecond.Where(fst => fst.Publisher.Contains(searchKey1))).ToList<oData.vwBook>() :
lstSecond.ToList<oData.vwBook>();
and I have Operator Dropdownlist with AND and OR. The problem is after selecting the operator Dropdownlist. If User select AND I have to combine 2 List with Union and then I have to filter like...
lstCombine = lstFirst.Union(lstSecond.ToList<oData.vwBook>()).ToList<oData.vwBook>();
//AND operator
lstCombine =(if searchField1 is Title or Author or Publisher which is equal to txtSearch1.Text) AND (if searchField2 is Title or Author or Publisher which is equal to txtSearch2.Text)
//OR operator
lstCombine =(if searchField1 is Title or Author or Publisher which is equal to txtSearch1.Text) OR (if searchField2 is Title or Author or Publisher which is equal to txtSearch2.Text)
Please help !
Best Regards,
Nyi Nyi Aung
</div>