DataSet to InfoDataSet

John Smith asked on August 4, 2017 16:51

Hello,

I am creating a small import from an old database to a new database. I am trying to see if there is a way to convert a source dataset to a target InfoDataSet

Correct Answer

John Smith answered on August 4, 2017 17:11

Thanks Trevor but I think I found a way to convert it now after looking more.

If I map the columns via SQL to the properties in the BaseInfo I can call InfoDataSet's constructor with the source dataset and it maps it perfectly.

Thank you for the information though!

0 votesVote for this answer Unmark Correct answer

Recent Answers


Trevor Fayas answered on August 4, 2017 16:59

The best way is to simply write a script to take the old data and map it to the new Info object type, as it will trigger any events and such.

However, you can just do a SQL Import if the following things are true:

  1. This is a single site, and there is no Staging enabled (if you have staging enabled, doing a database insert won't catch the changes)
  2. The destination is either a Custom Module class or a Custom Table. You never want to insert data into anything relating to the CMS_Tree (Tree Nodes) or Documents as there are many related tables.
  3. Object versioning is disabled for the object you are inserting into. If versioning is turned on, then doing an insert won't properly update the versioning.

If all of those are true, you would probably be very safe just doing a SQL insert of the data. If not, then just create a temporary ASPX page somewhere, add a button with onclick postback and add your .net code to insert the objects using Kentico's API.

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on August 4, 2017 17:32

Duh, i totally forgot about passing a DataRow to the constructor, yes that IS a great way to do it, much better than mine! I'll have to keep that in mind myself....

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.