Linq Order By

  • Thread starter Thread starter shapper
  • Start date Start date
S

shapper

Hello,

I have the following linq query:

viewData.TagPapers = (from t in database.Tags
select new TagPaper {
Tag = t,
Count = t.FileTag.Count
}).ToList;

How can I order it by Count value to display first the records that
have a higher Count value?

Thanks,
Miguel
 
shapper said:
I have the following linq query:

viewData.TagPapers = (from t in database.Tags
select new TagPaper {
Tag = t,
Count = t.FileTag.Count
}).ToList;

How can I order it by Count value to display first the records that
have a higher Count value?


viewData.TagPapers = (from t in database.Tags
orderby t.FileTag.Count descending
select new TagPaper {
Tag = t,
Count = t.FileTag.Count
}).ToList();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Linq. Take and OrderBy 7
Linq. Where 10
Linq. OrderBy and Where. 7
Linq > Group 2
Linq. Select 2
Linq. Why do I get this error? 4
List to CSV 3
Local Sequence cannot be used ... except the Contains() operator 4

Back
Top