I have a set of objects of type Idea
public class Idea
{
public string Title { get; set; }
public string Body { get; set; }
}
I managed to do this in memory with the following code:
public virtual ActionResult Search(string term)
{
var clientNames = from customer in DocumentSession.Query()
select new { label = customer.FullName };
var results = from name in clientNames.ToArray()
where name.label.Contains(term,
StringComparison.CurrentCultureIgnoreCase)
select name;
return Json(results.ToArray(), JsonRequestBehavior.AllowGet);
}
This saved me the trouble of going RavenDB way of searching for strings with Contains method as described by Daniel Lang's post.
The Contains
extension method is this:
public static bool Contains(this string source, string toCheck, StringComparison comp)
{
return source.IndexOf(toCheck, comp) >= 0;
}