Hi,
I am trying to understand difference between those two and really need a explanatory simple example for them.
Thanks in advance..
Hi,
I am trying to understand difference between those two and really need a explanatory simple example for them.
Thanks in advance..
InsertOnSubmit
adds a single record. InsertAllOnSubmit
does the same, but for a set (IEnumerable<T>
) of records. That's about it.
I found this example of InsertAllOnSubmit() at the very bottom of this page. Just remember to add a using statement for System.Collections.Generic
// Create list with new employees
List<Employee> employeesToAdd = new List<Employee>();
employeesToAdd.Add(new Employee() { EmployeeID = 1000, FirstName = "Jan", LastName = "Jansen", Country = "BE" });
employeesToAdd.Add(new Employee() { EmployeeID = 1001, FirstName = "Piet", LastName = "Pieters", Country = "BE" });
employeesToAdd.Add(new Employee() { EmployeeID = 1002, FirstName = "John", LastName = "Johnson", Country = "BE" });
// Add all employees to the Employees entityset
dc.Employees.InsertAllOnSubmit(employeesToAdd);
// Apply changes to database
dc.SubmitChanges();