linq中last或者lastordefault不存在的问题

在使用linq访问数据库的时候发现first以及firstordefault都存在,但是last以及lastordefault不存在。上网找寻一番发现是last只在linq to object中实现了的,没有在linq to sql中实现,因此需要使用asenumerable或者tolist将linq to sql转换成linq to object,然后使用last。当然,你可以使用orderby descending将数据库重新排列,使用前面的first。

原文地址:https://www.cnblogs.com/HelpQY/p/4117897.html