Been struggling with this and don't know how to implement. Seems easy of enough.
I have a search box that takes multiple keywords. I then take those keywords and pass them to my IENumerable method in my repository.
public IEnumerable<diss> GetDissSearch(string b)
Then I place keywords into array - b contains the string of words and use Split method.
string[] sArray = strSearchString.Split();
Then I use foreach loop to go words in my array, but within my foreach loop I place my linq statement as the following:
foreach(string s in sArray){
var myLoop = (from p in mytable
where p.userFirstName.Contains(s)
&& p.lastName.Contains(s)
select new myModel {
firstName = p.userFirstName,
lastName = p.userLastName
}).ToList();
return myLoop;
}
So if user enters two words - for example, a first and last name, you expect that the collection would be called twice. Similarly if user entered a middle name then collection would be called three times. At the moment, this collection is only run once.
Is there way to call this ienumerable multiple times based on the number of keywords contained in my array?
Thanks.