如图所示:
location = locationList.OrderBy(x => x.Piler).FirstOrDefault();//取到了第二条记录
location = locationList.OrderBy(x => x.Piler).ToList().FirstOrDefault();//取到了第一条记录
延迟加载导致的?不应该,我使用sql语句到数据库查询,没问题,这个问题触发的条件没搞明白。
目前只能先Task一条记录,再FirstOrDefault()
////此写法存在bug,未查清原因,FirstOrDefault()取到第二个元素 location = locationList.OrderBy(x => x.Piler).FirstOrDefault(); //取值正常 location = locationList.OrderBy(x => x.Piler).Take(1).FirstOrDefault();
标签:OrderBy,core,FirstOrDefault,Piler,locationList,ef,location,bug From: https://www.cnblogs.com/huanye63/p/17622461.html