Skip to content

Commit

Permalink
LINQ : Fixes ArgumentNullException while calling ToQueryDefinition() (#…
Browse files Browse the repository at this point in the history
…2580)

This fixes ArguementNullException in ToQueryDefinition for read feed scenarios where there has been no filters applied to the linq query.
  • Loading branch information
sourabh1007 authored Jun 30, 2021
1 parent 157fae2 commit 238e23a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Microsoft.Azure.Cosmos/src/Query/v3Query/QueryDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ internal static QueryDefinition CreateFromQuerySpec(SqlQuerySpec sqlQuery)
{
if (sqlQuery == null)
{
throw new ArgumentNullException(nameof(sqlQuery));
// It is to support scenarios where all the data needs to be read
return null;
}

QueryDefinition queryDefinition = new QueryDefinition(sqlQuery.QueryText);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,18 @@ async Task TestSearch(Expression<Func<ToDoActivity, bool>> expression, string ex

}

[TestMethod]
public async Task LinqSelectEverythingWithoutQueryableTest()
{
await ToDoActivity.CreateRandomItems(this.Container, pkCount: 2, perPKItemCount: 1, randomPartitionKey: true);

QueryDefinition queryDefinition = this.Container
.GetItemLinqQueryable<ToDoActivity>()
.ToQueryDefinition();

Assert.AreEqual(2, (await this.FetchResults<ToDoActivity>(queryDefinition)).Count);
}

private class NumberLinqItem
{
public string id;
Expand Down

0 comments on commit 238e23a

Please sign in to comment.