Is it possible to get Added items not committed in EFCore with .NET Core?

.net-core c# ef-core-2.0 entity-framework-core

Question

I need to query my Context in EF Core to get Added Items, but not Saved (EntityState.Added)

Example query:

var list = await _databaseContext.Set<PersonModel>().ToListAsync();

I see one topic about ChangeTracker, but I don't know how to implement here on this scenario. Is it possible on EF Core?

1
2
1/14/2019 3:03:08 AM

Accepted Answer

You can access the changes with the ChangeTracker property on your DbContext:

var added = _databaseContext.ChangeTracker.Entries().Where(x => x.State == EntityState.Added);
2
1/14/2019 3:39:16 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow