0
使用folowing函數返回一個SelectList。我需要在Descr上的自定義格式,但將Key.ToString()替換爲Key.ToString(「DD/MM/YY」)會給我提供錯誤「Method」System.String ToString(System.String)' SQL。「我如何在Descr上使用自定義日期格式?從Linq到SQL查詢的自定義日期格式
Public Function ReturnDates(ByVal Param_Pesq_Cod As Integer) As SelectList
Dim Qry = From E In DB.Execs _
Where E.Pesq_Cod = Param_Pesq_Cod _
Group E By Key = E.DataHora.Date _
Into Group Order By Key Select New With {.Descr = Key.ToString(), .Val = Key}
Return New SelectList(Qry, "Val", "Descr")
End Function