Question

I've got a piece of software that is adding entries to a context. using the changetracker I want to generate a List of Poco classes for reporting purposes.

Like this:

List<customRecord> addedRecords = context.ChangeTracker.Entries<customRecord>().Where(e => e.State == EntityState.Added).ToList();

the result is the following Error:

Cannot implicitly convert type 'System.Collections.Generic.List<System.Data.Entity.Infrastructure.DbEntityEntry<T>>' to 'System.Collections.Generic.List<T>'

is there some kind of way to achieve this?

Kind regards.

Was it helpful?

Solution

Add .Select(i => i.Entity)

List<customRecord> addedRecords = context.ChangeTracker.Entries<customRecord>().Where(e => e.State == EntityState.Added).Select(i => i.Entity).ToList();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top