var dbContext = new MyDbContext(); var list = new List{ new MyEntity { Name = "John Doe", Age = 29 }, new MyEntity { Name = "Jane Smith", Age = 35 } }; dbContext.MyEntities.AddRange(list); dbContext.SaveChanges();
var dbContext = new MyDbContext(); var query = from e in dbContext.MyEntities where e.Age > 30 select e; dbContext.MyEntities.AddRange(query); dbContext.SaveChanges();In this example, the `AddRange` method is used to add all MyEntity objects from a database query that meet a certain criteria to the MyEntities DbSet. The `AddRange` method is included in the Entity Framework package library.