[CSHARP-137] Make query builder more natural Created: 22/Dec/10  Updated: 02/Apr/15  Resolved: 20/Jan/11

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 0.5, 0.7, 0.9, 1.0
Fix Version/s: 0.11

Type: Improvement Priority: Major - P3
Reporter: Flavien Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

All


Backwards Compatibility: Fully Compatible

 Description   

When building a query with the query builder, some combinations throw an InvalidOperationException because the query underlying structure is a document, for instance:

Query.Or(
Query.EQ("name", "Flav"),
Query.EQ("name", "Flavien"),
Query.EQ("value", "Flavien")));

Throws an exception because the "name" attribute is defined twice on the document. This makes sense for a document, but doesn't for a query. The query builder should process the query to turn it seamlessly into a document, and not throw those kind of exceptions.

Also combining ORs inside ANDs should work, even if that is not supported by the engine, as the driver could change a query to its disjunctive form ( OR(AND(x, y), AND(a, b)) ), so that it is accespted by the engine.



 Comments   
Comment by Robert Stam [ 20/Jan/11 ]

Merged in Andrew's pull request. Thanks Andrew.

Comment by Andrew Rondeau [ 05/Jan/11 ]

Potentially fixed in pull request https://github.com/mongodb/mongo-csharp-driver/pull/36

Comment by Robert Stam [ 27/Dec/10 ]

Query.Or should already work. The duplicate name exception would occur when using Query.And.

Generated at Wed Feb 07 21:35:54 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.