我正在使用 Entity Framework 。我需要使用其主键查找记录。
我这样试试。
tabCom com = db.tabCom.Find(3);
但是有错误,它说
'System.Data.Objects.ObjectSet' does not contain a definition for 'Find' and no extension method 'Find' accepting a first argument of type 'System.Data.Objects.ObjectSet' could be found (are you missing a using directive or an assembly reference?)
如何使用主键查找数据。我的代码有什么问题还是有其他方法?
最佳答案
tabCom com = db.tabCom.Single(tab => tab.PrimaryKeyColumn == 3);
关于c# - 如何在 Entity Framework 中使用主键查找数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18435711/