question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

What is the default sorting of GetItemLinqQueryable?

See original GitHub issue

I want to construct a query with optional parameters in LINQ, basically this code:

IOrderedQueryable<User> query = _userContainer.GetItemLinqQueryable<User>();
if (id != null)
{
    query = query.Where(user => user.Id == id); // returns IQueryable
}
if (name != null)
{
    query = query.Where(user => user.Name == name); // returns IQueryable
}

This doesn’t work because IQueryable cannot be assigned to IOrderedQueryable which GetItemLinqQueryable returns.

To avoid doing an expensive sort operation my theory is that I can apply the same sorting that GetItemLinqQueryable uses in each of these if-blocks. I didn’t find the default sort mentioned in the documentation, so anyone knows what it is?


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
SaurabhSharma-MSFTcommented, Mar 2, 2022

@Sti2nd We are proceeding with the closure with the issue.

1reaction
SaurabhSharma-MSFTcommented, Feb 23, 2022

@Sti2nd The recommendation is to use GetItemQueryIterator for queries and the order in which the items are returned depends on the query. For a simple scan like SELECT * FROM c it would return in <partition, rid> order.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Container.GetItemLinqQueryable<T> Method
(Optional) An IOrderedQueryable{T} that can evaluate the query. Examples. This example below shows LINQ query generation and blocked execution. C#
Read more >
GetItemLinqQueryable doesn't return any items
I believe your issue has to do with how the linq query in serialized. By default GetItemLinqQueryable doesn't use camel case.
Read more >
Error when using OrderBy on field with possible NULL ...
Specifies that the values in the specified column should be sorted in ascending or descending order. ASC sorts from the lowest value to...
Read more >
Using LINQ to Query Dynamic Schema-less ... - Jeremy Likness
I have a database named url-tracking with a container named url-stats . Cosmos DB Database and Container. I set up these names in...
Read more >
Specifying default sort order in EF using query interceptors
So first, I need a way to somehow define the property which the sorting should be based on, and somehow also indicate the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found