How to use Intersect Operator with Entity Framework

Goldytech
Posted by Goldytech under Others category on | Views : 10401
This sample snippet shows you how to use the Intersect Operator in Entity Framework.
The output of this snippet is the common products that are shipped to India and China

public void IntersectExample()
{
var India = context.OrderDetails.Where(od => od.Order.ShipCountry == "India").Select(od => od.Product);
var China = context.OrderDetails.Where(od => od.Order.ShipCountry == "China").Select(od => od.Product);

var CommonProductsShipped = India.Intersect(China);


}

Comments or Responses

Login to post response