猿问

如何使用动态字符串参数执行OrderBy?

我想做这个:


var orderBy = "Nome, Cognome desc";


var timb = time.Timbratures.Include("Anagrafica_Dipendente")

    .Where(p => p.CodDipendente == 1);


if(orderBy != "")

    timb = timb.OrderBy(orderBy);

是否有OrderBy可以接受字符串参数的重载?


撒科打诨
浏览 622回答 3
3回答
随时随地看视频慕课网APP
我要回答