x.Id.StartsWith() translates bad if precedes .OrderBy().ThenBy()

30 views
Skip to first unread message

Ivan Montilla

unread,
Dec 11, 2019, 6:33:25 AM12/11/19
to RavenDB - 2nd generation document database
This query works as expected:

await Session.Query<Vadavo.Vicim.Areas.Customers.Entities.Contract>()
            .Where(x => x.Id.StartsWith($"contracts/{Customer.Id}/"))
            .Select(x => new ContractModel
            {
                Name = x.Name,
                Type = x.Type.ToString()
            })
            .ToArrayAsync();

Is translated into:

from Contracts as x where startsWith(id(), $p0) select { Name : x.Name, Type : x.Type.toString() }

That is ok, but if I add OrderBy().ThenBy(), the where clause is translated bad:

await Session.Query<Vadavo.Vicim.Areas.Customers.Entities.Contract>()
            .Where(x => x.Id.StartsWith($"contracts/{Customer.Id}/"))
            .OrderBy(x => x.Type)
            .ThenBy(x => x.Name)
            .Select(x => new ContractModel
            {
                Name = x.Name,
                Type = x.Type.ToString()
            })
            .ToArrayAsync();

Is translated into:

from Contracts as x where startsWith(x.Id, $p0) order by Type, Name select { Name : x.Name, Type : x.Type.toString() }

Notice that where clause now compare x.Id instead id()


Egor Shamanaev

unread,
Dec 12, 2019, 10:52:23 AM12/12/19
to rav...@googlegroups.com
Hi Ivan,

Thanks for your post,

This is a bug, 
https://issues.hibernatingrhinos.com/issue/RavenDB-14363  

--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ravendb/4de7771d-4926-493c-a9ae-40e2be8e3b15%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages