一直在搜索使用聚合值对IQueryable进行排序(使用Linq To SQL)的快速示例。通过VB.net中的聚合对IQueryable进行排序
我基本上需要计算几个派生值(两个值之间的百分比差异等),并通过这个结果排序。
即
返回rows.OrderBy(功能(S)CalcValue(s.Visitors,s.Clicks))
我想调用外部函数来计算聚合。这应该实现IComparer吗?或IComparable?
感谢
[编辑] 曾尝试使用:
Public Class SortByCPC : Implements IComparer(Of Statistic)
Public Function Compare(ByVal x As Statistic, ByVal y As Statistic) As Integer Implements System.Collections.Generic.IComparer(Of Statistic).Compare
Dim xCPC = x.Earnings/x.Clicks
Dim yCPC = y.Earnings/y.Clicks
Return yCPC - xCPC
End Function
End Class
的LINQ to SQL不使用的IComparer
不喜欢我
我不能让这对LINQ工作要SQL的IQueryable – 2008-12-16 03:55:41