简体   繁体   中英

Entity Framework .Find with Where clause

I have something like the following in my code:

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

I was not able to figure out how I can add a where clause to the Find statement.

You cannot Find method only searches by primary key. If you want to use a condition use Single , First , FirstOrDefault or SingleOrDefault instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM