Closed gautiers closed 12 years ago
I tried with the version 1.3.1 and I have the same behavior
Yeah. I haven't had a chance to look at this yet. I'll try and get to it in the next couple days.
The problem does not occur if the collection is of type ICollection<string> instead of string [] So this works : AsQueryable().Where( c => c.Searches.Contains( mySearch ) )
But this : AsQueryable().Where( c => c.Searches.Any( s => s.StartsWith(mySearch) ) ) still does not work, it says that "The mongo field must be the operator for a string operation of type StartsWith" The corresponding MongoQuery would be : { "Searches" : /mySear*/ }
This should be fixed in release 1.3.1.1.
Using 1.3.11
AsQueryable().Where( m => m.Name.ToUpper().StartsWith( name.ToUpper() ) );
I get InvalidQueryException, The mongo field must be the operator for a string operation of type StartsWith
Correct, you can only call StartsWith on a field. There is no way in mongo to uppercase a field at the server side...
However, you can perform a case-insensitive regex search instead... Regex.IsMatch(m.Name, name, RegexOptions.CaseInsensitive)... or something like that.
Hello,
I have a Contact class
_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 think it should be translated in something like { "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