Created
August 28, 2012 11:58
-
-
Save benfoster/3497518 to your computer and use it in GitHub Desktop.
RavenDB querying one range using another
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (criteria.HasSalaryCriteria) | |
{ | |
var salaryFrom = criteria.SalaryFrom ?? 0; | |
var salaryTo = criteria.SalaryTo ?? int.MaxValue; | |
query.AndAlso() | |
.OpenSubclause() | |
// is Criteria.From between Salary.From and Salary.To? | |
.OpenSubclause() | |
.WhereLessThanOrEqual("SalaryFrom", salaryFrom) | |
.AndAlso() | |
.WhereGreaterThanOrEqual("SalaryTo", salaryFrom) | |
.CloseSubclause() | |
// OR is Criteria.To between Salary.From and Salary.To | |
.OpenSubclause() | |
.WhereLessThanOrEqual("SalaryFrom", salaryTo) | |
.AndAlso() | |
.WhereGreaterThanOrEqual("SalaryTo", salaryTo) | |
.CloseSubclause() | |
// OR is Criteria.SalaryRange greater than Salary.Range | |
.OpenSubclause() | |
.WhereGreaterThanOrEqual("SalaryTo", salaryFrom) | |
.AndAlso() | |
.WhereLessThanOrEqual("SalaryTo", salaryTo) | |
.CloseSubclause() | |
.CloseSubclause(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment