What’s the best way in asp.net mvc to take my array and save each element (and attaching a parentId to each as well) to my sql server db in one step?
thanks,
rodchar
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Have a look at the SqlBulkCopy class. This allows you to bulk copy data into a table in a single call.
Typically, this is used to load data into a staging table, followed by a further call (usually to a stored procedure) which moves the data from the staging table to production table(s).
You may, however, choose to use it to append data directly to a production table.
The approach you choose will obviously be driven by how your database is engineered and the particular data you are loading.