IEnumerable(Of Contact) の OrderBy メソッドが取るのと同じ型である Func(Of Contact, TKey) 型の並べ替えパラメーターを取る GetAllContacts メソッドを作成したいと考えています。これが私のコードです:
Public Function GetAllContacts(Of TKey)(ByVal sort As Func(Of Contact, TKey), ByVal sortDirection As SortDirection) As IEnumerable(Of Contact) Implements IContactRepository.GetAllContacts
Select Case sortDirection
Case sortDirection.Ascending
Return ContactList.OrderBy(sort)
Case sortDirection.Descending
Return ContactList.OrderByDescending(sort)
End Select
End Function
GetAllContacts(Func(c) c.ContactID, SortDirection.Ascending) を呼び出すと、エラーが発生します。
"Value of type 'System.Func(Of Contact, String)' cannot be converted to 'Integer'." on the first parameter
と
"Too many arguments to extension method 'Public Function ElementAtOrDefault(index As Integer) As Contact' defined in 'System.Linq.Enumerable'." on the second parameter.
私は何が欠けていますか?