Add .Select(i => i.Entity)
List<customRecord> addedRecords = context.ChangeTracker.Entries<customRecord>().Where(e => e.State == EntityState.Added).Select(i => i.Entity).ToList();
質問
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.
解決
Add .Select(i => i.Entity)
List<customRecord> addedRecords = context.ChangeTracker.Entries<customRecord>().Where(e => e.State == EntityState.Added).Select(i => i.Entity).ToList();