mercredi 23 décembre 2015

Insert/update database dynamically with Entity Framework

I've to import the values of multiple SharePoint 2013 lists in a SQL Server database using Entity Framework. I thought to use two database tables where store the names of the lists and the related columns with the database tables and columns and with these informations to loop automatically inserting/updating the database.

These are the tables where I store list informations:

SP List to SQL Server mapping tables

For example there is a SharePoint list called Person with column Name, Surname and Age where Age is a Choice field as drop down containing numbers. From T_SPLists and T_SPColumns I know that all the data goes into Person table with this mapping:

  • Name ---> Name
  • Surname ---> Surname
  • Age is a foreign key in Person table and I've to check in the lookup table if the value exists; if not add it in lookup table and insert the correct id into Person table (the final user will ask to insert a new value in the drop down everytime he will need it), if already exists get the id and insert into Person table

How can I do it with Entity Framework? I hope I have been clear.

Thank you





Aucun commentaire:

Enregistrer un commentaire