Migration: How to migrate DocumentQuery from 3.x

There were many changes to DocumentQuery regarding specific functionalities. We encourage you to read about them in their respective articles, but the biggest change that this particular article wants to address is the default operator change.

In the previous version of RavenDB, there was a discrepancy between Query and DocumentQuery in regards to the default operator. The Query was using AND and DocumentQuery was using OR. Now both of those types of query are using the same operator AND.

Example I

Retrieve all employees which FirstName is John or Bob by using the UsingDefaultOperator method.

3.x
List<Employee> results = session
    .Advanced
    .DocumentQuery<Employee>()
    .WhereEquals(x => x.FirstName, "John")
    .WhereEquals(x => x.FirstName, "Bob")
    .ToList();
4.0
List<Employee> results = session
    .Advanced
    .DocumentQuery<Employee>()
    .UsingDefaultOperator(QueryOperator.Or)
    .WhereEquals(x => x.FirstName, "John")
    .WhereEquals(x => x.FirstName, "Bob")
    .ToList();

Example II

Retrieve all employees which FirstName is John or Bob using OrElse method.

3.x
List<Employee> results = session
    .Advanced
    .DocumentQuery<Employee>()
    .WhereEquals(x => x.FirstName, "John")
    .WhereEquals(x => x.FirstName, "Bob")
    .ToList();
4.0
List<Employee> results = session
    .Advanced
    .DocumentQuery<Employee>()
    .WhereEquals(x => x.FirstName, "John")
    .OrElse()
    .WhereEquals(x => x.FirstName, "Bob")
    .ToList();

Do you need any help with Migration?