Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 实体框架.Find with Where子句_C#_Entity Framework - Fatal编程技术网

C# 实体框架.Find with Where子句

C# 实体框架.Find with Where子句,c#,entity-framework,C#,Entity Framework,我的代码中有如下内容: dbContext.Progs .Remove(dbContext.Progs.Find(pNum)); dbContext.SaveChanges(); 我无法找到如何将where子句添加到Find语句中。您无法Find方法仅按主键搜索。如果要使用条件,请使用Single、First、FirstOrDefault或SingleOrDefault。Find假定您正在通过主键搜索单个记录。如果要使用其他条件进行搜索,请

我的代码中有如下内容:

      dbContext.Progs
               .Remove(dbContext.Progs.Find(pNum));
      dbContext.SaveChanges();

我无法找到如何将
where
子句添加到
Find
语句中。

您无法
Find
方法仅按主键搜索。如果要使用条件,请使用
Single
First
FirstOrDefault
SingleOrDefault

Find
假定您正在通过主键搜索单个记录。如果要使用其他条件进行搜索,请使用
Where
(或
Single
,或
First
等)。您正在使用哪个版本的entityframework?