I am making a sql query and I want to have the linq sql syntax.
Query SQL:
SELECT TOP 3 * FROM Customer
WHERE CustomerID NOT IN (SELECT TOP 3 CustomerID FROM Customer ORDER BY CustomerID)
Please suggest a solution.
Thanks!
CodePudding user response:
TOP makes no sense without an ORDER BY.
Assuming you're paging the results sorted by the customer ID, try:
List<Customer> page = context.Customers
.OrderBy(c => c.CustomerID)
.Skip(3).Take(3)
.ToList();
