Last and LastOrDefault not supported

后端 未结 7 1068
孤独总比滥情好
孤独总比滥情好 2020-12-03 09:47

I am trying to get the first and last values in a list. The query operator First() is supported but Last() and LastOrDefault() give an

7条回答
  •  南方客
    南方客 (楼主)
    2020-12-03 09:59

    either you switch your OrderBy to

    .OrderByDescending(p => p.BillID)
    

    (and use first) or you do something like

    purchaseBills.ToArray().Last()
    

    if this is not to expensive.

提交回复
热议问题