Skip to content

WahidBitar/EF-Core-Simple-Graph-Update

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Digital Wink Entity Framework Extensions

In this simple project we're going to expose the helper extenasion methods that we're using in our company. and as a starting point we'll start witht the Graph update method. We'll update the Nuget Package whenever we have a new version.

Entity Framework Core Simple Graph Update

It's a simple update method that will help you to do a full update to an aggregate graph with all related entities in it. the update method will take the loaded aggregate entity from the DB and the passed one that may come from the API layer. Internally the method will update just the eager loaded entities in the aggregate "The included entities"

var updatedSchool = mapper.Map<School>(apiModel);

var dbSchool = dbContext.Schools
    .Include(s => s.Classes)
    .ThenInclude(s => s.Students)
    .FirstOrDefault();

dbContext.InsertUpdateOrDeleteGraph(updatedSchool, dbSchool);

dbContext.SaveChanges();

Please don't hesitate to contribute or give us your feedback and/or advice 🌹 🌹

About

Update an aggregate graph with all related entities

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages