Created
August 27, 2012 18:21
-
-
Save benfoster/3491067 to your computer and use it in GitHub Desktop.
RavenDB WhereAll extension method
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
public static IDocumentQuery<T> WhereAll<T>(this IDocumentQuery<T> query, string fieldName, object[] values) | |
{ | |
if (values == null || values.Length == 0) | |
throw new ArgumentException("Cannot be a null or empty array.", "values"); | |
query.OpenSubclause(); | |
query.WhereEquals(fieldName, values[0]); | |
for (int i = 1; i < values.Length; i++) | |
{ | |
query.AndAlso().WhereEquals(fieldName, values[i]); | |
} | |
query.CloseSubclause(); | |
return query; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment