I am making a website based on a Sql Server DB which is still in using by another application. The website is using a MySQL DB since is a SSH website. So I created a a new MySQL database for it and migrated all the data from Sql Server to MySQL . Since the Sql Server DB is still in use, it is updating everyday. I can't do the migration job everyday. So I am gonna make a program that read in tables (only 3 tables in the DB is used for the website.But each table has more than 3000 records) from Sql Server DB and insert those tables into MySQL database. I am using Dapper for the program. I can read out the tables as lists e.g. List. Just wondering is there a good way to insert these lists into MySQL DB. I am using a for loop to insert the lists into DB now. Is there a better way? Thaks.
you can add object into your list by this.
List< table> tbl= new List< table>();
foreach (table tblname in collection)
{
table tblNew= new table {
field1 = tblname .field1,
field2 = tblname.field2
};
tbl.Add(imgSIgn);
}
int res= cn.Execute(@"Insert INTO table(field1,field2) VALUES (@field1,@field2)", tbl.ToArray());