这有什么问题吗?
int folderid = (from p in db.folder where p.isDefault == true select p.id).Last();
i get this error
LINQ to Entities does not recognize the method 'Int32 Last[Int32]
(System.Linq.IQueryable`1[System.Int32])' method, and this method cannot be
translated into a store expression.
FirstOrDefault()
不会出错。但是我还是给你点赞,这是正确的方法。 - Wiktor ZychlaSingle()
жҲ–иҖ…SingleOrDefault()
жӣҙеҠ зӣҙи§Ӯеҗ—пјҹ - MarcinJuraszekSingle()
。如果它可能为空,则建议使用SingleOrDefault()
。感谢指出这一点。 - Arion