Skip to content

Instantly share code, notes, and snippets.

@benfoster
Created August 27, 2012 18:21
Show Gist options
  • Save benfoster/3491067 to your computer and use it in GitHub Desktop.
Save benfoster/3491067 to your computer and use it in GitHub Desktop.
RavenDB WhereAll extension method
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