I have a statement like so:
var vals =
from StandAloneUserPayment saup in _Session.Query<StandAloneUserPayment>()
.Fetch(x => x.RecurringPayments)
where
saup.User.UserId == userId
&& searchString.Contains(saup.FriendlyName, StringComparer.InvariantCultureIgnoreCase)
select
saup;
This seems to be exactly what I’m supposed to do, but I get the whole line with the Contains method underlined with the following message:
stringdoes not contain a definition forContainsand the best extension method overloadSystem.Linq.ParallelEnumerable.Contains<TSource>(System.Linq.ParallelQuery<TSource>, TSource, System.Collections.Generic.IEqualityComparer<TSource>)has some invalid arguments
What am I doing wrong?
Try
IndexOf:The reason it doesn’t work is because the
Containsextension method that accepts anIEqualityComparer<TSource>is operating on aString, which implementsIEnumerable<char>, notIEnumerable<string>, so astringand anIEqualityComparer<string>can’t be passed to it.