Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad request with Linq Query #35

Closed
Daxez opened this issue Apr 29, 2014 · 1 comment
Closed

Bad request with Linq Query #35

Daxez opened this issue Apr 29, 2014 · 1 comment

Comments

@Daxez
Copy link

Daxez commented Apr 29, 2014

Using the TableSet class with a predefined Entity I ran a Linq query, which resulted in a bad request. When I viewed the request/response in Fiddler I ran into strange behavior:

The Linq Query was:

(from item in _table
 where item.CreateDate > mindate && item.ProcessName == processName 
&& (item.CreateDay == currentPartition || item.CreateDay == nextPartition || item.CreateDay == prevPartition)
select item)

Where CreateDate is a DateTime? and mindate is a valid DateTime.
CreateDay and current/prev/nextPartition are both strings as well as processName. _table is the TableSet in this case. The Entity is strongly typed and the columns are all available in storage.

The request sent by the application was (URL decoded):

$filter=CreateDate gt datetime'2014-04-29T12:12:49.5952511Z' and ProcessName eq 'xxxxxxxxxxx') and ((PartitionKey eq '2014042912' or PartitionKey eq '2014042913') or PartitionKey eq '2014042911'

Naturally this resulted in a bad request. While running the query manually with the closing bracket after [ProcessName eq 'xxxxxxxxxxx'] moved to the end of the query resulted in a 200.

Rewriting the query to

var existing = (from item in _table
              where (item.CreateDay == currentPartition || item.CreateDay == nextPartition || item.CreateDay == prevPartition)
             select item).ToList();

existing = existing.Where(f => f.CreateDate > mindate && f.ProcessName == processName).ToList();

did the job, but retrieves a bigger set from the server than needed.

@dtretyakov
Copy link
Owner

Thank you for posting, it'll be fixed in the next version.

dtretyakov added a commit that referenced this issue Feb 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants