vish kv
vish kv

Reputation: 19

How to sort data got from database?

I have a Details object of type Investigator which I get from the database like this:

Investigator Details = RepositoryContext.RegistryRep.GetInvestigator(user.Id);

It is getting 20 number of result. Each one has property place and investigatorname.

So I want to get only details which has property place as india.

I need to sort from the total item to reduced no.of item which has property place=india

Result should be of type investigator.

How to do that?

Upvotes: 0

Views: 55

Answers (1)

Oluwafemi
Oluwafemi

Reputation: 14889

You need to use Linq

Investigator result = Details.OrderBy(x => x.investigatorname)
                      .Where(x => x.place == "india").ToList();

Upvotes: 1

Related Questions