How to use Except predicate in Entity Framework

Posted by Goldytech under Others category on | Views : 11675
This sample snippet shows you how could you use Except predicate in EF.
The below code gets list of Customers except from cutomers orders not shipped in China. This works similiar to Not clauase or <> operator in T-SQL

public void ExceptEF()
var query = context.Customers.Select(e => e)
.Except(context.Orders.Where(o => o.ShipCountry == "China").Select(o => o.Customer));

Comments or Responses

Login to post response