0

我需要sort一个基于col1除以col2..的结果所以我想做的是这样的:

var x = uploadsQuerySelectionBuilder.Where(e => e.uploadNumberOfVotes 
> 0)**.OrderByDescending(e=>(e.uploadScore/e.uploadNumberOfVotes))
** : uploadsQuerySelectionBuilder;

至于现在..它似乎根本没有订购结果,但它只是随机的..这甚至可能吗,我该如何让它工作?

编辑:

var x = tSearch.SortByDate != false ? uploadsQuerySelectionBuilder.Where(e => e.uploadNumberOfVotes > 0).OrderByDescending(e => (e.uploadScore / e.uploadNumberOfVotes)) : uploadsQuerySelectionBuilder;

是非常有效且“可编译”的代码:)..另一个不是用VS编写的,所以我的错..

4

1 回答 1

0

就像是:

var x = uploadsQuerySelectionBuilder
           .Where(e => e.uploadNumberOfVotes > 0)
           .Select(e => new { Val = e, ScoreishThing = e.uploadScore/e.uploadNumberOfVotes })
           .OrderByDescending(e=> e.ScoreishThing)
           .Select(e=>e.Val);
于 2012-09-18T09:23:33.243 回答