简体   繁体   中英

Why is there no call to repository's update method for this request (Entity Framework, automapper, repository pattern)?

I am trying to understand the code in following screenshot. After map operation, the object is not written back to the repository. What is this concept called? How does SaveChangesAsync make call to the update method on the repository?

在此处输入图像描述

How does SaveChangesAsync make call to the update method on the repository?

The DbContext is the repository, and it's tracking the oldCamp object. When SaveChagnes () is called it will detect changes to any tracked entities and take the appropriate action (insert,update or delete).

Under the hood SaveChangesAsync() will automatically call DetectChanges() to discover any changes to entity instances before saving to the underlying database. This can be disabled via AutoDetectChangesEnabled .

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