0

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!

1
  • explain more by add new and complete info, more people can help u Commented Jan 11, 2022 at 9:27

1 Answer 1

3

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();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.