RavenDB Linq Invalid Operation.ToUpperInvariant ()

I am trying to use ToUpperInvariant() in a LINQ query with RavenDB. I get an InvalidOperationException :

Unable to figure out how to translate .Name.ToUpperInvariant () server.

Request below. What needs to happen so that I can match by name here? Is this possible in a query using RavenDB?

 public ApplicationServer GetByName(string serverName) { return QuerySingleResultAndCacheEtag(session => session.Query<ApplicationServer>() .Where(server => server.Name.ToUpperInvariant() == serverName.ToUpperInvariant()).FirstOrDefault()) as ApplicationServer; } protected static EntityBase QuerySingleResultAndCacheEtag(Func<IDocumentSession, EntityBase> func) { if (func == null) { throw new ArgumentNullException("func"); } using (IDocumentSession session = Database.OpenSession()) { EntityBase entity = func.Invoke(session); if (entity == null) { return null; } CacheEtag(entity, session); return entity; } } 
+6
source share
1 answer

As indicated in the exception, the server does not understand ToUpperInvariant() . As far as I know, RavenDB uses the LowerCaseKeywordAnalyzer custom method, so by default, queries are not case sensitive. See the RavenDB documentation on analyzers for more details .

+8
source

Source: https://habr.com/ru/post/904921/


All Articles