1

a question on how to add a "SELECT TOP" query in asp.net mvc3

            var applicant = from s in applicantRepository.GetApplicant()
                       select s;

in my applicant there is i think 200,000 datas and i just want to select the top 50

is that possible? Thanks KUDOS! :)

3 Answers 3

2

To return the top 50 rows in any order

var applicant = 
    (from s in applicantRepository.GetApplicant()
    select s).Take(50);

if you want to apply ordering, say there's a LastName field

var applicant = 
    (from s in applicantRepository.GetApplicant()
    orderby s.LastName
    select s).Take(50);
Sign up to request clarification or add additional context in comments.

Comments

2

Use Take and Skip accordingly. For example, to take second 10 applicants:

var applicant = 
  (from s in applicantRepository.GetApplicant()
   select s).Skip(10).Take(10);

Comments

1

Use the Take extension method:

var applicant = (from s in applicantRepository.GetApplicant()
                       select s).Take(50);

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.