craiggwilson/fluent-mongo — Issue #43: StringArray.Contains( "string" ) translated in { StringArray :  [ 's' , 't' , 'r' , 'i' , 'n' , 'g' ] }
Author: gautiers
Created: 2011-12-02 17:04:17+00:00
State: open

Hello,

I have a Contact class

public class Contact
{
private string _firstname;
private string _lastname;
private string _company;

private string [] _searches;

....

[corresponding properties]
}

_searches array contains lower case / without accent version of _firstname, _lastname, _company as items

So I would like to do : AsQueryable().Where( c => c.Searches.Contains( mySearch ) )

And i was expecting that it would be translated in something like { $elemMatch : { "Searches" : mySearch } }

But in the log, i have : { Searches: [ 103, 97, 117, 116, 105, 101, 114 ] }
where the numbers are the ascii code of each letter of "mySearch" (the real search was "gautier")

Same thing with AsQueryable().Where( c => c.Searches.Any( s => s == mySearch ) )

Am I doing something wrong here ?

Next step would be to use AsQueryable().Where( c => c.Searches.Any( s => s.StartsWith(mySearch) ) )
Here it tells me that StartsWith has to be used on the mongo field
But i think it is. Or am i missing something ?

Thank you