tags:

views:

50

answers:

1

Hello,

I thought I would throw an omni-search on my data.

So I made a function that returns any match on a string.

ex.

var results = (from d in db.MyData
where new string[]{ d.DataField1.ToString(), d.DataField2.ToString(), ... }.Contains(searchTerm)
select d);

But when I try to iterate over it I get The expression of type 'System.String[]' is not a sequence.

//blows up on first iteration
foreach(var v in results)
{...}

Can anyone give me a few pointers?

Thanks!

+3  A: 

I ran that query in Linqpad and it ran, but not how you wanted. It didn't do a LIKE against each field inside %'s, it did an IN against the set, which would only match if the data matched exactly. Can you just write it out?

var results = (from d in db.MyData
  where d.DataField1.Contains(searchTerm) || d.DataField2.Contains(searchTerm)
  select d);
Scott Stafford
<3 <3 <3 <3 <3 <3 Good call, an omni search should not need an exact match. Thanks!
Biff MaGriff