我有一个软件正在向上下文添加条目。 使用changetracker我想生成一个Poco类列表用于报告目的。
像这样:
List<customRecord> addedRecords = context.ChangeTracker.Entries<customRecord>().Where(e => e.State == EntityState.Added).ToList();
结果是以下错误:
Cannot implicitly convert type 'System.Collections.Generic.List<System.Data.Entity.Infrastructure.DbEntityEntry<T>>' to 'System.Collections.Generic.List<T>'
有某种方法可以达到这个目的吗?
亲切的问候。
答案 0 :(得分:1)
添加.Select(i => i.Entity)
List<customRecord> addedRecords = context.ChangeTracker.Entries<customRecord>().Where(e => e.State == EntityState.Added).Select(i => i.Entity).ToList();