Hi Experts,
I'm a beginner with LINQ so I would appreciate any help.
I'm trying to insert a lot of rows into my database. The obvious way would be to do something like this:
DestinationDbDataContext newDb = new DestinationDbDataContext();
var userRole1 = new Role { Name = "Administrator", Description = "Administrator User" };
var userRole2 = new Role { Name = "Tech", Description = "Technical Support" };
var userRole3 = new Role { Name = "Sales", Description = "Sales Person" };
var userRole4 = new Role { Name = "Accounting", Description = "Accounting Department" };
newDb.Roles.InsertOnSubmit(userRole1);
newDb.Roles.InsertOnSubmit(userRole2);
newDb.Roles.InsertOnSubmit(userRole3);
newDb.Roles.InsertOnSubmit(userRole4);
newDb.SubmitChanges();
but of course this is not very efficient. Can you help me think of a way to to move LINQ stuff into a separate method so all I'd have to do is to pass the Table name , values and maybe field names and have LINQ handle everything separately.
Thank you in advance!