Linq Order By

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
 
M

Martin Honnen

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

Top