Session: Querying: How to use intersect?

To return only documents that match all provided sub-queries we have introduced Intersect extension that enables us to do server-side intersection queries.


IRavenQueryable<T> Intersect<T>(this IQueryable<T> self) { ... }
Return Value
IRavenQueryable Instance implementing IRavenQueryable interface containing additional query methods and extensions.


// return all T-shirts that are manufactured by 'Raven'
// and contain both 'Small Blue' and 'Large Gray' types
List<TShirt> tshirts = session
		.Query<TShirt, TShirts_ByManufacturerColorSizeAndReleaseYear>()
		.Where(x => x.Manufacturer == "Raven")
		.Where(x => x.Types.Any(t => t.Color == "Blue" && t.Size == "Small"))
		.Where(x => x.Types.Any(t => t.Color == "Gray" && t.Size == "Large"))